summaryrefslogtreecommitdiff
path: root/test/files/jvm/actor-uncaught-exception.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/jvm/actor-uncaught-exception.scala')
-rw-r--r--test/files/jvm/actor-uncaught-exception.scala46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/files/jvm/actor-uncaught-exception.scala b/test/files/jvm/actor-uncaught-exception.scala
new file mode 100644
index 0000000000..9f64be26e1
--- /dev/null
+++ b/test/files/jvm/actor-uncaught-exception.scala
@@ -0,0 +1,46 @@
+import scala.actors.{Actor, Exit}
+
+class MyException(msg: String) extends Exception(msg) {
+ override def fillInStackTrace() = this
+}
+
+object Test {
+
+ case object StartError extends Actor {
+ def act() {
+ throw new MyException("I don't want to run!")
+ }
+ }
+
+ case object MessageError extends Actor {
+ def act() {
+ react {
+ case _ => throw new MyException("No message for me!")
+ }
+ }
+ }
+
+ case object Supervisor extends Actor {
+ def act() {
+ trapExit = true
+ link(StartError)
+ link(MessageError)
+ StartError.start()
+ MessageError.start()
+
+ Actor.loop {
+ react {
+ case Exit(actor, reason) =>
+ if (actor == StartError)
+ MessageError ! 'ping
+ else
+ exit()
+ }
+ }
+ }
+ }
+
+ def main(args: Array[String]) {
+ Supervisor.start()
+ }
+}