There are two situations where i need to deal with exceptions outside of 
the normal "Let it crash" paradigm.
First is an actor that can't crash. I have some actors that cache a ton of
information and their startup can take quite a while. If some method throws
in the actor unless the exception is absolutely destructive I dont want to
restart the actor ever. Now I can put a try-catch in the recieve method but
that seems to be a little heavyweight, or put a try-catch in the sub
methods but that will require me to wrap every message handler in
try-catch. So I am wondering what people's opinion are on the best
The second situation is an endpoint actor that serves an HTTP request. If
this actor throws I want to return a standard error message to the user,
not just leave them hanging, this is complicated by the fact that I have a
general EndpointActor that implements a ton of boilerplate functionality
and many endpoints extend this, so if I put a try-catch in the endpoint
actor's receive loop it wouldnt matter if the subclass overrides that loop.
Of course I could require the user to do the same try-catch but then that
seems boilerplate so I am not comfortable with that either.
Any thoughts on best practices?
kraythe 's gravatar image asked Apr 1 2017 at 12:17 in Akka-User by kraythe

0 Answers

Related Discussions