diff options
Diffstat (limited to 'examples/scala-js/library/src/main/scala/scala/scalajs/runtime/UndefinedBehaviorError.scala')
-rw-r--r-- | examples/scala-js/library/src/main/scala/scala/scalajs/runtime/UndefinedBehaviorError.scala | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/examples/scala-js/library/src/main/scala/scala/scalajs/runtime/UndefinedBehaviorError.scala b/examples/scala-js/library/src/main/scala/scala/scalajs/runtime/UndefinedBehaviorError.scala new file mode 100644 index 0000000..b06ed7d --- /dev/null +++ b/examples/scala-js/library/src/main/scala/scala/scalajs/runtime/UndefinedBehaviorError.scala @@ -0,0 +1,23 @@ +package scala.scalajs.runtime + +import scala.util.control.ControlThrowable + +/** Error thrown when an undefined behavior in Fatal mode has been detected. + * This error should never be caught. It indicates a severe programming bug. + * In Unchecked mode, the program may behave arbitrarily. + * The `cause` is set to the exception that would have been thrown if the + * given behavior was in Compliant mode. + * If your program relies on the proper kind of exception being thrown, as if + * running on the JVM, you should set the appropriate behavior to Compliant. + * Note that this will have (potentially major) performance impacts. + */ +class UndefinedBehaviorError(message: String, cause: Throwable) + extends java.lang.Error(message, cause) with ControlThrowable { + + def this(cause: Throwable) = + this("An undefined behavior was detected" + + (if (cause == null) "" else ": "+cause.getMessage), cause) + + override def fillInStackTrace(): Throwable = + super[Error].fillInStackTrace() +} |