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
In case of errors, most APIs will return an error JSON object describing details of what happened.
How would you go about getting that? My attempt looks very clunky (slightly rewritten to show the problem).
private fun parseResponse(response: ResponseBody): Either<FailureResponse, SuccessResponse> {
return try {
success(serializer.parse<SuccessResponse>(response))
} catch (e1: KlaxonException) {
// if planned success parsing failed, try parsing to a FailureResponse
return try {
failure(serializer.parse<FailureResponse>(response)))
} catch (e2: KlaxonException) {
failure(SerialisationFailure.fromException(e1))
}
} catch (e: IllegalArgumentException) {
// Likely caused by Enum.valueOf() when deserializing to enums. Make sure enum is complete.
failure(SerialisationFailure.fromException(e))
}
}
The text was updated successfully, but these errors were encountered:
In case of errors, most APIs will return an error JSON object describing details of what happened.
How would you go about getting that? My attempt looks very clunky (slightly rewritten to show the problem).
The text was updated successfully, but these errors were encountered: