With HttpResponseValidator
fun
T : HttpClientEngineConfig HttpClientConfig
T.exceptionHandling() {
HttpResponseValidator {
handleResponseExceptionWithRequest { exception, _ ->
val type = when (exception) {
is ClientRequestException -> RemoteExceptionType.CLIENT_ERROR
is ServerResponseException -> RemoteExceptionType.SERVER_ERROR
is JsonConvertException -> RemoteExceptionType.PARSING_ERROR
else -> RemoteExceptionType.UNKNOWN
}
throw RemoteException(type)
}
}