I was never too clear on how to cleanly handle exc...
# coroutines
d
I was never too clear on how to cleanly handle exceptions with Channels in the first place, is there maybe a good article or reference on the subject (apart from the guides on Github that don't really go into best practices the different cases that could occur...)
l
You're consuming the channels, right? If yes, then it means they are
finally
closed. Don't consume them if you don't want them to
finally
be closed
d
Nope, I use for (event in channel).... but the exception somehow doesn't let it go on... maybe if it propogates from suspend fun, it gets swallowed and is not caught by the try catch in the call site? I have an actor that calls another one, that calls a suspend fun that sometimes crashes, and both actors for loops have try catches around them, the only thing is that I pass a CompletableDeferred down all the way to the suspend fun and call completedExceptionally... which is how I lock the original caller's thread until the whole event processing is finished and the next one can be handled (its an android sync adapter's service...), maybe that throws? It's all a bit confusing...
v
d
That's likely.. thanks! I guess I'll have to go back to my channel launch implementation until the new version is out.