https://kotlinlang.org logo
#coroutines
Title
# coroutines
s

streetsofboston

07/09/2019, 3:33 PM
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

Matt Thompson

07/10/2019, 1:25 AM
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

streetsofboston

07/10/2019, 10:48 AM
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

elizarov

07/11/2019, 8:09 AM
Yes. It is
CoroutineExceptionHandler
is inherited.
👍 1
2 Views