Skip to content

Instantly share code, notes, and snippets.

@jamie-allen
Created May 20, 2015 19:08
Show Gist options
  • Save jamie-allen/d88122cf8e91eb14a40c to your computer and use it in GitHub Desktop.
Save jamie-allen/d88122cf8e91eb14a40c to your computer and use it in GitHub Desktop.
import akka.actor.Actor
import akka.actor.OneForOneStrategy
import akka.actor.SupervisorStrategy.Stop
import akka.actor.ActorSystem
import akka.actor.Props
import akka.actor.ActorInitializationException
class TestActorParent extends Actor {
override val supervisorStrategy = OneForOneStrategy() {
case a: ActorInitializationException => {
println("GOT THE AIE")
Stop
}
case StartUpException => {
println("GOT HERE!")
Stop
}
}
val child = context.actorOf(Props[TestActorChild])
def receive = {
case _ => println("got parent message")
}
}
case object StartUpException extends Exception
class TestActorChild extends Actor {
override def preStart = {
throw StartUpException
}
def receive = {
case _ => println("got child message")
}
}
object Bootstrap extends App {
val system = ActorSystem()
system.actorOf(Props[TestActorParent])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment