Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -833,9 +833,8 @@ class SupervisionSpec extends ScalaTestWithActorTestKit("""

"support nesting to handle different exceptions" in {
val probe = TestProbe[Event]("evt")
val behv = Behaviors
.supervise(Behaviors.supervise(targetBehavior(probe.ref)).onFailure[Exc2](SupervisorStrategy.resume))
.onFailure[Exc3](SupervisorStrategy.restart)
val behv =
targetBehavior(probe.ref).onFailure[Exc2](SupervisorStrategy.resume).onFailure[Exc3](SupervisorStrategy.restart)
val ref = spawn(behv)
ref ! IncrementState
ref ! GetState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ package akka.actor.typed
import scala.annotation.switch
import scala.annotation.tailrec
import scala.reflect.ClassTag

import akka.actor.InvalidMessageException
import akka.actor.typed.internal.BehaviorImpl
import akka.actor.typed.internal.BehaviorImpl.DeferredBehavior
import akka.actor.typed.internal.BehaviorImpl.StoppedBehavior
import akka.actor.typed.internal.BehaviorTags
import akka.actor.typed.internal.CachedProps
import akka.actor.typed.internal.InterceptorImpl
import akka.actor.typed.scaladsl.Behaviors
import akka.annotation.DoNotInherit
import akka.annotation.InternalApi
import akka.util.OptionVal
Expand Down Expand Up @@ -146,6 +146,10 @@ object Behavior {
def transformMessages[Outer: ClassTag](matcher: PartialFunction[Outer, Inner]): Behavior[Outer] =
BehaviorImpl.transformMessages(behavior, matcher)

/** Specify the [[SupervisorStrategy]] to be invoked when the wrapped behavior throws. */
def onFailure[Thr <: Throwable](strategy: SupervisorStrategy)(implicit tag: ClassTag[Thr]): Behavior[Inner] =
Behaviors.supervise(behavior).onFailure(strategy)(tag)

}

/**
Expand Down