-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
ControlThrowable.scala
47 lines (44 loc) · 1.33 KB
/
ControlThrowable.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* Scala (https://www.scala-lang.org)
*
* Copyright EPFL and Lightbend, Inc.
*
* Licensed under Apache License 2.0
* (http://www.apache.org/licenses/LICENSE-2.0).
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/
package scala.util.control
/** A parent class for throwable objects intended for flow control.
*
* Instances of `ControlThrowable` should not normally be caught.
*
* As a convenience, `NonFatal` does not match `ControlThrowable`.
*
* {{{
* import scala.util.control.{Breaks, NonFatal}, Breaks.{break, breakable}
*
* breakable {
* for (v <- values) {
* try {
* if (p(v)) break
* else ???
* } catch {
* case NonFatal(t) => log(t) // can't catch a break
* }
* }
* }
* }}}
*
* Suppression is disabled, because flow control should not suppress
* an exceptional condition. Stack traces are also disabled, allowing
* instances of `ControlThrowable` to be safely reused.
*
* Instances of `ControlThrowable` should not normally have a cause.
* Legacy subclasses may set a cause using `initCause`.
*/
abstract class ControlThrowable(message: String) extends Throwable(
message, /*cause*/ null, /*enableSuppression=*/ false, /*writableStackTrace*/ false) {
def this() = this(message = null)
}