Packages

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
Linear Supertypes
Serializable, Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Exceptional
  2. Serializable
  3. Serializable
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. 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.

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

    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.