Coroutines do not log uncaught exceptions in Android
See original GitHub issuehttps://github.com/wardellbagby/KotlinExceptions
I created a sample app to show what I mean.
When a coroutine has an uncaught exception, it’s manually calling the Thread UncaughtExceptionHandler
. A consequence of that is Android’s uncaught exception pre-handler that handles logging isn’t invoked.
The README of the linked project goes more in depth.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:11
- Comments:12 (7 by maintainers)
Top Results From Across the Web
Exceptions in coroutines. Cancellation and Exceptions in…
The exception isn't caught because the handler is not installed in the right CoroutineContext . The inner launch will propagate the exception up...
Read more >Exception not being caught in Coroutines - Stack Overflow
Trying with CoroutineExceptionHandler can be workaround for handling exceptions inside coroutines. CoroutineExceptionHandler context element ...
Read more >Coroutine Exception Handling & Observability with Firebase
When an uncaught exception is thrown, its current coroutine breaks with CancellationException. By default, with the mechanism of structured concurrency, the ...
Read more >Why exception handling with Kotlin Coroutines is so hard and ...
Key Point #1. If a Coroutine doesn't handle exceptions by itself with a try-catch clause, the exception isn't re-thrown and can't, therefore, ...
Read more >Coroutine exceptions handling | Kotlin
It is possible to customize the default behavior of printing uncaught exceptions to the console. CoroutineExceptionHandler context element on a ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve just spent hours debugging a simple issue. Whats the current best practice for getting uncaught exceptions on android?
@saied89 Do you have
kotlinx-coroutines-android
module added to your dependencies?