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

dave08

05/31/2018, 5:25 PM
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

louiscad

05/31/2018, 10:06 PM
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

dave08

06/01/2018, 1:54 AM
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

Vsevolod Tolstopyatov [JB]

06/01/2018, 8:13 AM
d

dave08

06/01/2018, 10:54 AM
That's likely.. thanks! I guess I'll have to go back to my channel launch implementation until the new version is out.
6 Views