Print stack trace of an exception in Kotlinx.Coroutinekotlin/coroutine/exception-handlerBy default, Kotlinx.Coroutine will not print stack trace of an exception. This snippet will print stack trace of an exception.
1fun CoroutineExceptionHandler(key: String) = kotlinx.coroutines.CoroutineExceptionHandler { _, exception ->
2 logger.error("$key coroutine uncaught exception", exception)
3}Disclaimer
The code snippet is provided for reference and learning purposes only. Users should use it at their own risk. I, along with the related developers, shall not be held responsible for any direct or indirect losses caused by the use of this code snippet, including but not limited to data loss, computer malfunctions, program errors, etc.