kotlinx.coroutines
kotlinx.coroutines copied to clipboard
Provide an API to check whether debug mode is enabled
We already have a notion of debug mode in our documentation, but we do not have an API to check whether the mode is enabled.
It can be useful in multiple scenarios:
- To write unit tests that work both with and without debug mode
- We already do that in our MPP tests
- To verify and debug program behaviour (see #2550)
- To write your own extensions to coroutines that may exhibit an additional behaviour when debug mode is enabled (stacktrace for cancellation exception subclasses, context markers and so on)
Also, it's worth adding unwrap function and separate stacktrace recovery check.
We already bump into this in our own modules: https://github.com/Kotlin/kotlinx.coroutines/pull/2646/commits/89fd2c179efcd5a80d5dd2f12ada5a75734e9326