Ktorfit icon indicating copy to clipboard operation
Ktorfit copied to clipboard

Ktorfit cant handle validation exceptions

Open naixx opened this issue 1 year ago • 2 comments

Ktorfit version

2.0.0

What happened and how can we reproduce this issue?

Add custom validation to ktor

HttpResponseValidator {
            validateResponse {
                 throw MyHttpException()
            }
}

This exception is not propagated to coroutine suspension function.

try{
   myCoroutine()
catch(e: MyHttpException)

But if you throw any subtype of ResponseException, you will be able to catch it.

What did you expect to happen?

Any exception is propagated to coroutine

Is there anything else we need to know about?

No response

naixx avatar Aug 26 '24 16:08 naixx

It just tried to reproduce it, the exception is propagated to the catch block and then to the exceptionhandler https://github.com/Foso/Ktorfit/blob/237e2133f12935377626a7c6fba50980efc982de/example/AndroidOnlyExample/app/src/main/java/de/jensklingenberg/androidonlyexample/MainActivity.kt#L79

Foso avatar Aug 26 '24 18:08 Foso

I suspect, it is not catched in catch as iI would expect, but in handler as you've mentioned

naixx avatar Aug 26 '24 18:08 naixx