question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Coroutines do not log uncaught exceptions in Android

See original GitHub issue

https://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:closed
  • Created 6 years ago
  • Reactions:11
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

6reactions
saied89commented, Nov 7, 2018

I’ve just spent hours debugging a simple issue. Whats the current best practice for getting uncaught exceptions on android?

4reactions
elizarovcommented, Nov 7, 2018

@saied89 Do you have kotlinx-coroutines-android module added to your dependencies?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found