the test is failing because the exception gets bubbled up to the runblocking although I’m using an exception handler. Doing some debugging I’ve seen that the handler is set in the right child context, but still never called. Does anybody know why?
ah! gotcha, thanks for pointing it out, didn’t know that. So in general when you are in an inner context it’s a good practice to use a try catch instead?
s
sean
08/28/2020, 11:14 PM
If I'm planning on catching an exception I catch it on the
await()
call returned from
async { }
within a
supervisorScope
sean
08/28/2020, 11:14 PM
otherwise, you can try catch within the coroutine itself no problem
e
Evan R.
08/31/2020, 3:10 AM
Alternatively coroutineScope rethrows exceptions from launched coroutines so you can wrap that in a try catch as well
a
Andrea Giuliano
09/03/2020, 2:55 PM
for future reference, if you use
supervisedScope
then you can inject the errorHandler and it works as expected