You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I currently need to use this interceptor to get access to the code from the response to be used in my error catch:
// This retrieves the error code from the response
// as this is not accessible in the Supabase client RestException
// to handle fatal Postgres errors
supabaseClient.httpClient.httpClient.plugin(HttpSend).intercept { request ->
val resp = execute(request)
val response = resp.response
if (response.status.value == 400) {
val responseText = response.bodyAsText()
try {
val error = Json { coerceInputValues = true }.decodeFromString<Map<String, String?>>(responseText)
errorCode = error["code"]
} catch (e: Exception) {
Logger.e("Failed to parse error response: $e")
}
}
resp
}
Ideally, I could just do something like this
catch(e: Exception) {
when (e) {
is BadRequestRestException -> {
(if e.code = some code) {
// Handle error
}
}
}
The text was updated successfully, but these errors were encountered:
Alright, I think the best way is to add a custom exception for Postgrest (like the AuthRestException) exposing these properties.
But nonetheless, we can also expose the whole response in the RestExceptions in general.
I'll take a look at it and see if we can make it into 3.1.0.
General Info
Feature request
Please can the
response
be included in theRestException
as I need access to thecode
that is in the response?(Similar change happened here d3ee40f)
Usecase
I currently need to use this interceptor to get access to the code from the response to be used in my error catch:
Ideally, I could just do something like this
The text was updated successfully, but these errors were encountered: