From 69e1ddb55a7f122715dbed337de73f595ae00dc3 Mon Sep 17 00:00:00 2001 From: Miles Sabin Date: Wed, 15 Jul 2009 13:01:43 +0000 Subject: Added ControlException marker trait and update ... Added ControlException marker trait and update various exceptions to mix it in; the typer now correctly propagates ControlExceptions rather than reporting them; the IDE reports attempts to log ControlExceptions; Global.signalDone no longer leaks ValidateErrors back into the typer; the set of compiler options offered by the IDE has been updated. --- .../scala/runtime/NonLocalReturnException.scala | 3 +- src/library/scala/util/control/Breaks.scala | 2 +- .../scala/util/control/ControlException.scala | 39 ++++++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 src/library/scala/util/control/ControlException.scala (limited to 'src/library') diff --git a/src/library/scala/runtime/NonLocalReturnException.scala b/src/library/scala/runtime/NonLocalReturnException.scala index 7bb7b99341..2884a0ce9f 100644 --- a/src/library/scala/runtime/NonLocalReturnException.scala +++ b/src/library/scala/runtime/NonLocalReturnException.scala @@ -13,8 +13,9 @@ package scala.runtime import Predef.RuntimeException +import scala.util.control.ControlException -class NonLocalReturnException[T](val key: AnyRef, val value: T) extends RuntimeException { +class NonLocalReturnException[T](val key: AnyRef, val value: T) extends RuntimeException with ControlException { /* * For efficiency reasons we do not fill in * the execution stack trace. diff --git a/src/library/scala/util/control/Breaks.scala b/src/library/scala/util/control/Breaks.scala index 3315140b6b..25adf80573 100755 --- a/src/library/scala/util/control/Breaks.scala +++ b/src/library/scala/util/control/Breaks.scala @@ -44,5 +44,5 @@ class Breaks { /** A singleton object providing the Break functionality */ object Breaks extends Breaks -private class BreakException extends RuntimeException +private class BreakException extends RuntimeException with ControlException diff --git a/src/library/scala/util/control/ControlException.scala b/src/library/scala/util/control/ControlException.scala new file mode 100644 index 0000000000..4ac7b0ceeb --- /dev/null +++ b/src/library/scala/util/control/ControlException.scala @@ -0,0 +1,39 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ + +package scala.util.control + +/** + * A marker trait indicating that the Throwable it is mixed + * into is intended for flow control. + * + *

Note that Throwable subclasses which extend this trait + * may extend any other Throwable subclass (eg. + * RuntimeException) and are not required to extend + * Throwable directly.

+ * + *

Instances of Throwable subclasses marked in + * this way should not normally be caught. Where catch-all behaviour is + * required ControlExceptions should be propagated, for + * example,

+ * + *
+ *  import scala.util.control.ControlException
+ *
+ *  try {
+ *    // Body might throw arbitrarily
+ * } catch {
+ *   case ce : ControlException => throw ce // propagate
+ *   case t : Exception => log(t)           // log and suppress
+ * 
+ * + * @author Miles Sabin + */ +trait ControlException extends Throwable -- cgit v1.2.3