Updated on 2026-08-14

This commit is contained in:
Tangem 2023-01-10 11:42:49 +03:00
parent 7794446857
commit 5d448b9500
87 changed files with 223 additions and 121 deletions

View file

@ -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
}
}
}