I have a question on how Exceptions are handled in...
# coroutines
s
I have a question on how Exceptions are handled in Coroutines that run within a
SupervisorJob
. To me it seems the code has a bug in how exceptions propagate (or not) to the parent of a Coroutine run within a SupervisorJob. I logged the issue here: https://github.com/Kotlin/kotlinx.coroutines/issues/1317 Can someone shed a light on how this is supposed to work? I’m a bit baffled 🙂 Thanks!
m
Hey Anton, the documentation for
supervisorScope
might explain it:
The provided scope inherits its coroutineContext from the outer scope, but overrides context’s Job with SupervisorJob.
- so in this case
cehParent
would be inherited as the the context and handle the exception, I don't think it's propagating the error to the parent
launch
s
Aha! Thank you! Inherits its context. That could indeed be the case, and this would make sense for what I observe. Let's confirm with one of the Coroutine masters 😀 @elizarov Is this correct? Although, CoroutineExceptionHandlers don't participate in the inherit/override chain for parent/child `Job`s, they do seem to be inherited/overridden when moving to a child
SupervisorJob
... Is this what happens?
e
Yes. It is
CoroutineExceptionHandler
is inherited.
👍 1