With HttpResponseValidator
fun T : HttpClientEngineConfig HttpClientConfigT.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)
}
}
h
Hasan Nagizade
10/23/2023, 8:27 AM
unknown host exception is not possible to catch with this.
k
khalid64927
10/23/2023, 8:45 AM
Then you can always wrap your request block with run catching