Supervision: Getting hold of Exception

Let’s take a simple example:

Behaviors.supervise {
  Behaviors.receiveMessage[Command] { [..] }
}.onFailure[Throwable](SupervisorStrategy.resume)

How can I get hold of the Throwable, process it and than resume the actor?

You can have different onFailure handlers for different types of exceptions, but more details of the exception than that is by design not available. The reason is that the supervisor strategy should not do too much. Typically the supervisor strategy should be selected by the parent actor that is spawning the behavior. Communicating between the child and parent via exceptions is not a good approach.

If you need to handle exceptions in more detail it should probably be part of the message handler, i.e. using an ordinary try-catch when processing the message.