object Exceptional extends Serializable
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.
- Source
- Outcome.scala
- Alphabetic
- By Inheritance
- Exceptional
- Serializable
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
def
apply(e: Throwable): Exceptional
Creates an
Exceptional
instance given the passedThrowable
.Creates an
Exceptional
instance given the passedThrowable
.If the passed
Throwable
is an instance ofTestCanceledException
, this method will returnCanceled
containing thatTestCanceledException
. Otherwise, it returns aFailed
containing theThrowable
.For example, trait
SeveredStackTraces
uses this factory method to sever the stack trace of the exception contained in either aFailed
andCanceled
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
orCanceled
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 aFailed
andCanceled
like this:abstract override def withFixture(test: NoArgTest): Outcome = { super.withFixture(test) match { case Exceptional(e: StackDepth) => Exceptional(e.severedAtStackDepth) case o => o } }
- res
the
Outcome
to extract the throwable from.- returns
a
Some
wrapping the contained throwable ifres
is an instance of eitherFailed
orCanceled
, elseNone
.