Unreadable stack trace
Closed this issue · 3 comments
I start my coroutine with launch
and then use await
on the Deferred
type returned from my retrofit interface.
The stack trace of the exception thrown from the insides of adapter looks like this:
06-11 02:02:06.041 13607-13607/com.example E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example, PID: 13607
retrofit2.HttpException: HTTP 404 Not Found
at com.jakewharton.retrofit2.adapter.kotlin.coroutines.experimental.CoroutineCallAdapterFactory$BodyCallAdapter$adapt$2.onResponse(CoroutineCallAdapterFactory.kt:104)
at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:123)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:153)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
This trace is not useful since it does not trace to the original caller of await
.
I'm new to coroutines and Kotlin, is there a way to make the stack trace more informative?
This trace is not useful since it does not trace to the original caller of
await
.
This is the case with all coroutine usage. The original caller's stack is gone as it wasn't blocked on waiting for the response.
You can nest the exception in another inside your catch clause since that will be in your calling code location and therefore produce a trace that contains a usage location.
There's nothing we can do here. This library is moving upstream anyway to square/retrofit#2886 which should provide a better experience.