summaryrefslogtreecommitdiff
path: root/library/src/main/scala/scala/scalajs/runtime/UndefinedBehaviorError.scala
blob: b06ed7d714c66f632db6f9cc58b12bb5e8f40986 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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()
}