someone else exeperienced exceptions thrown by ret...
# android
a
someone else exeperienced exceptions thrown by retrofit which are not caught by the try catch surounding the call ?
j
Which exception are you referring to and what’s on you catch clause?
a
Copy code
GlobalScope.launch(handler) {
            try {
                someSuspendingFunctionWhichAlsoCallsRetrofit()
            } catch (it: Throwable) {
                logError(it)
            }
        }
--> E/AndroidRuntime: FATAL EXCEPTION: main
catch and exceptionHandler are not called just get this Androidruntime exception (which should be a unknownhostexception, but is appreaently cut by android since some newer versions )
in the end i maed my retrofit client blocking an wrapped it myself in coroutines
👍 1
g
Could you please show full stacktrace
a
unfortunately thats all Android gives me
Copy code
E/AndroidRuntime: FATAL EXCEPTION: main
i assume it it an UnkownHostException, it seems like retrofit throws the exception two times and one time it is not catched
p
I did experience that behavior with okhttp async api. Some Network errors were not caught internally by the library. I ended up wrapping the sync api in a try/catch on my own Observable using RXjava. Then later I migrated that to coroutines Flow. I end up with an extension method in Call<T> class named asFlow that internally wraps the sync call in a try/catch. It then emits a result or throws.
j
Use 2.6.1
🙌 1
a
@jw thx, i already read your post before and updated but it didnt help me unfortunately