ControlThrowable

scala.util.control.ControlThrowable
abstract class ControlThrowable(message: String) extends Throwable

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.

Attributes

Source
ControlThrowable.scala
Graph
Supertypes
class Throwable
trait Serializable
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Constructors

def this()

Attributes

Source
ControlThrowable.scala

Inherited methods

Attributes

Inherited from:
Throwable

Attributes

Inherited from:
Throwable

Attributes

Inherited from:
Throwable

Attributes

Inherited from:
Throwable

Attributes

Inherited from:
Throwable

Attributes

Inherited from:
Throwable
final def getSuppressed(): Array[Throwable]

Attributes

Inherited from:
Throwable

Attributes

Inherited from:
Throwable

Attributes

Inherited from:
Throwable

Attributes

Inherited from:
Throwable

Attributes

Inherited from:
Throwable

Attributes

Inherited from:
Throwable
def toString(): String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Inherited from:
Throwable