Currently, the very last exception handler in coroutines is Thread.currentThread.defaultUncaughtExceptionHandler().uncaughtException.
While being robust, in the case of a large coroutines-heavy system it may be quite hard to track down the source of a programmatic bug, when an exception with a non-recovered stacktrace is just printed to the console.
To simplify such debugging, my proposal is to add a special ContextHolder (name TBD) exception to suppressed ones prior to passing the original to the uncaught exception handler. Such exception will lack stacktrace, but will provide access to the responsible coroutine context, both programmatically and when the original exception is printed to the console, effectively pinning down the source of the exception
The text was updated successfully, but these errors were encountered: