Exceptional

org.scalatest.Exceptional
See theExceptional companion class
object 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.

Attributes

Companion
class
Graph
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type

Members list

Type members

Inherited types

type MirroredElemLabels <: Tuple

The names of the product elements

The names of the product elements

Attributes

Inherited from:
Mirror
type MirroredLabel <: String

The name of the type

The name of the type

Attributes

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
 }
}

Attributes

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.

Attributes

Returns

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