@groostav It looks like all you need is to call this top level fun to create your handler instance (it's in the core lib.):
Copy code
public actual inline fun CoroutineExceptionHandler(crossinline handler: (CoroutineContext, Throwable) -> Unit): CoroutineExceptionHandler =
object: AbstractCoroutineContextElement(CoroutineExceptionHandler), CoroutineExceptionHandler {
override fun handleException(context: CoroutineContext, exception: Throwable) =
handler.invoke(context, exception)
}
I think you were missing the CoroutineContext's element key companion object, which is what replaces your context with the default one in the lib, but the above should do the trick...
🤔 1
g
groostav
01/30/2018, 7:22 AM
this function is a factory, I was using an alternative strategy to create it, but in either event, it never gets called. If i call this function, assign it to handler, and then do
runBlocking(Handler)
it still doesnt get called
groostav
01/30/2018, 7:44 AM
does it maybe have to do with the
runBlocking
builder, where the exception-handler only gets notified on
launch
blocks?
d
dave08
01/30/2018, 7:59 AM
Oh, I think that 0.22 ignores contexts in runBlocking, but I think 0.22.1 it was fixed... (for the dispatcher part, not sure about error handlers...)
dave08
01/30/2018, 8:05 AM
But in the source code (even old), it seems just to add contexts, not ignore them... I'd first update to 0.22.1 and maybe try