Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add contextual information to last-ditch exception handler #3153

Closed
qwwdfsad opened this issue Jan 24, 2022 · 0 comments
Closed

Add contextual information to last-ditch exception handler #3153

qwwdfsad opened this issue Jan 24, 2022 · 0 comments

Comments

@qwwdfsad
Copy link
Member

qwwdfsad commented Jan 24, 2022

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

qwwdfsad added a commit that referenced this issue Feb 1, 2022
…he original exception prior to passing it to the Thread.currentThread().uncaughtExceptionHandler()

Fixes #3153
dee-tree pushed a commit to dee-tree/kotlinx.coroutines that referenced this issue Jul 21, 2022
…he original exception prior to passing it to the Thread.currentThread().uncaughtExceptionHandler() (Kotlin#3170)

Fixes Kotlin#3153
pablobaxter pushed a commit to pablobaxter/kotlinx.coroutines that referenced this issue Sep 14, 2022
…he original exception prior to passing it to the Thread.currentThread().uncaughtExceptionHandler() (Kotlin#3170)

Fixes Kotlin#3153
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants