Updated on 2026-08-14
This commit is contained in:
parent
7794446857
commit
5d448b9500
87 changed files with 223 additions and 121 deletions
|
|
@ -0,0 +1,27 @@
|
|||
package com.tangem.utils.coroutines
|
||||
|
||||
import kotlinx.coroutines.CoroutineExceptionHandler
|
||||
import java.io.PrintWriter
|
||||
import java.io.StringWriter
|
||||
import java.util.logging.Level
|
||||
import java.util.logging.Logger
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
class FeatureCoroutineExceptionHandler {
|
||||
|
||||
// add an external logger (FbAnalytics) for handling errors
|
||||
companion object {
|
||||
fun create(from: String): CoroutineExceptionHandler = CoroutineExceptionHandler { _, throwable ->
|
||||
val sw = StringWriter()
|
||||
throwable.printStackTrace(PrintWriter(sw))
|
||||
val exceptionAsString: String = sw.toString()
|
||||
//it delegates logging to android Logger, cause cant use timber in java module
|
||||
Logger.getLogger("CoroutineExceptHandler").log(
|
||||
Level.INFO, "CoroutineException: from: $from, exception: $exceptionAsString",
|
||||
)
|
||||
throw throwable
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue