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

acando86

06/08/2018, 11:45 AM
What are the best practises for exception handling inside of an actors? Any unhandled exception gets propagated to the actors' channel, so the actor will not react to further incoming messages. I understand the more the codebase is using actors, the more this allows to model the entire architecture in a different way and handle the recovery logic at a higher level. But sometimes I might be using actors just in a specific area of the codebase to save a state without having to deal with thread confinement myself (eg, like the example of the counter in the kotlin docs), and in such a case maybe (?) i want to protect the actor from failures with some explicit try catch inside the actor itself. Is this a bad idea? Are there any preferred patterns to dead with this? Any suggestion?
e

elizarov

06/08/2018, 2:15 PM
Starting with new version unhandled errors in
actor
are now propagated to
CoroutineExceptionHandler
and you can customize its behavior.
e

elizarov

06/09/2018, 7:15 AM
No. Deferred is a future that fully incapsulates its result (including a potential error). You are always supposed to handle (
await
) all deferred’s that you have, so exception is never going to be lost.
👍 1
4 Views