Exceptional

Companion object to class Exceptional that provides a factory method and an extractor that enables patterns that match both Failed and Canceled outcomes and extracts the contained exception and a factory method.

Companion:
class
trait Sum
trait Mirror
class Object
trait Matchable
class Any

Type members

Inherited types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Inherited from:
Mirror

Value members

Concrete methods

def apply(e: Throwable): Exceptional

Creates an Exceptional instance given the passed Throwable.

Creates an Exceptional instance given the passed Throwable.

If the passed Throwable is an instance of TestCanceledException, this method will return Canceled containing that TestCanceledException. Otherwise, it returns a Failed containing the Throwable.

For example, trait SeveredStackTraces uses this factory method to sever the stack trace of the exception contained in either a Failed and Canceled like this:

abstract override def withFixture(test: NoArgTest): Outcome = {
 super.withFixture(test) match {
   case Exceptional(e: StackDepth) => Exceptional(e.severedAtStackDepth)
   case o => o
 }
}
Returns:

a Failed or Canceled containing the passed exception.

def unapply(res: Outcome): Option[Throwable]

Extractor enabling patterns that match both Failed and Canceled outcomes, extracting the contained exception.

Extractor enabling patterns that match both Failed and Canceled outcomes, extracting the contained exception.

For example, trait SeveredStackTraces uses this extractor to sever the stack trace of the exception contained in either a Failed and Canceled like this:

abstract override def withFixture(test: NoArgTest): Outcome = {
 super.withFixture(test) match {
   case Exceptional(e: StackDepth) => Exceptional(e.severedAtStackDepth)
   case o => o
 }
}
Value parameters:
res

the Outcome to extract the throwable from.

Returns:

a Some wrapping the contained throwable if res is an instance of either Failed or Canceled, else None.