Quantcast
Channel: Akka Libraries - Discussion Forum for Akka technologies
Viewing all articles
Browse latest Browse all 1362

How to get exception information in akka.actor.typed.SupervisorStrategy?

$
0
0

when there is some problem(e.g. db Exception,biz Exception) in an Actor, I hope the actor can throw exception in which some detail error message included to it’s supervisor. The supervisor then can perform diffrent strategy(not just akka strategy,but also include some logic I custom) according to the error message.
In akka.actor.typed.SupervisorStrategy, I can obtain the exception instance in the below way :

		strategy =
				new OneForOneStrategy(maxRetry, withinTimeRange,
						DeciderBuilder
								.match(ArithmeticException.class, e -> SupervisorStrategy.resume())
								.match(NullPointerException.class, e -> SupervisorStrategy.restart())
								.match(IllegalArgumentException.class, e -> SupervisorStrategy.stop())
								.matchAny(o -> SupervisorStrategy.escalate())
								.build());

but in the akka.actor.typed.SupervisorStrategy,the demo code like this:

Behaviors.supervise(
        Behaviors.supervise(behavior)
            .onFailure(IllegalStateException.class, SupervisorStrategy.restart()))
    .onFailure(IllegalArgumentException.class, SupervisorStrategy.stop());

I can only obatin the Exception class info, I can’t obtain the Exception instance info.Do you have some way to get the exception instance?

thank you !

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 1362

Trending Articles