Benoît
03/22/2021, 10:45 AMCoroutineExceptionHandler
Swift object
Has anyone managed to fix this issue?Michal Klimczak
03/22/2021, 11:29 AMBenoît
03/22/2021, 11:38 AMbsimmons
03/22/2021, 11:39 AMBenoît
03/23/2021, 9:31 PMbsimmons
03/24/2021, 1:01 PMNSError
to log a non-fatal exception, but right before, I log the real stack trace as a string in the log.Benoît
03/24/2021, 2:40 PMstackTraceToString()
from the standard library, I do it in the Kotlin code. The Swift Code receives the Throwable and calls a helper function I've made:
fun exceptionToString(exception: Throwable): String = exception.freezeObject().stackTraceToString()
However this isn't useful, the String it gives me looks like that:
kotlin.NotImplementedError: An operation is not implemented. at 0 shared 0x00000001014dd688 shared + 382600 at 1 shared 0x00000001014d6810 shared + 354320 at 2 shared 0x00000001014ca470 shared + 304240 at 3 shared 0x00000001014ca574 shared + 304500 at 4 shared 0x0000000101943c28 shared + 4996136 at 5 shared 0x0000000101945ca4 shared + 5004452 at 6 shared 0x0000000101917688 shared + 4814472 at 7 shared 0x00000001019187ec shared + 4818924 at 8 shared 0x0000000101686ca0 shared + 2124960 at 9 shared 0x0000000101688518 shared + 2131224 at 10 shared 0x0000000101688808 shared + 2131976 at 11 shared 0x00000
bsimmons
03/24/2021, 3:01 PMEither
then wrap your Kotlin code in runCatching
and convert it to an Either<String, MyData>
and pass back the exception as a string stack trace. Then in Swift you avoid exceptions altogether and already have the formatted string.Benoît
03/24/2021, 3:10 PM