Packages

final case class Safe[-I, +O, +E](alterand: Stage[I, O, E]) extends Alterator[Stage[I, O, E], I, O, Either[Throwable, E]] with SafeStage[I, O, Either[Throwable, E]] with Product with Serializable

A decorator that catches non-fatal exceptions thrown by the inner stage and converts them into h8io.stages.Status.Complete error values.

The error type is widened from E to Either[Throwable, E]:

  • Errors already carried by the inner stage are wrapped as Right(e).
  • Exceptions caught during apply are reported as Left(throwable) in a Yield.None(Status.error(Left(e)), this).

Only non-fatal exceptions (matched by scala.util.control.NonFatal) are caught; fatal errors such as OutOfMemoryError propagate normally.

The evolution is mapped so that every continuation stage remains wrapped in Safe, maintaining exception safety across the entire pipeline.

Safe is a crutch for the simplest cases — stateless stages. Per the Lifecycle contract in h8io.stages.Stage, a stage that throws from apply has already released its own resources, so the recovered continuation simply reuses the inner stage — retrying it on the next input — and carries a no-op dispose. A stage that owns resources should be made safe by itself instead of being wrapped: extend h8io.stages.base.SafeStage and supply a recover with the appropriate cleanup (the h8io.stages.base.ConstEvolution overload taking a dispose function exists for exactly this).

I

the input type (contravariant)

O

the output type (covariant)

E

the original error type of the inner stage (covariant)

alterand

the inner stage whose exceptions should be caught

Linear Supertypes
Serializable, Serializable, Product, Equals, SafeStage[I, O, Either[Throwable, E]], Alterator[Stage[I, O, E], I, O, Either[Throwable, E]], Stage[I, O, Either[Throwable, E]], (I) ⇒ Yield[I, O, Either[Throwable, E]], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Safe
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. SafeStage
  7. Alterator
  8. Stage
  9. Function1
  10. AnyRef
  11. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Safe(alterand: Stage[I, O, E])

    alterand

    the inner stage whose exceptions should be caught

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. val alterand: Stage[I, O, E]

    The wrapped stage whose behavior is modified by this operator.

    The wrapped stage whose behavior is modified by this operator.

    Definition Classes
    Safe → Alterator
  5. def andThen[A](g: (Yield[I, O, Either[Throwable, E]]) ⇒ A): (I) ⇒ A
    Definition Classes
    Function1
    Annotations
    @unspecialized()
  6. final def apply(in: I): Yield[I, O, Either[Throwable, E]]

    Processes in and returns the Yield carrying the optional output, the status and the continuation.

    Processes in and returns the Yield carrying the optional output, the status and the continuation.

    A stage that throws from here must have released its own resources first — see the Lifecycle section above.

    Definition Classes
    SafeStage → Stage → Function1
  7. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  8. def body(in: I): Yield[I, O, Either[Throwable, E]]

    The main execution logic invoked on each input.

    The main execution logic invoked on each input.

    in

    the input value

    returns

    a h8io.stages.Yield representing the result

    Definition Classes
    Safe → SafeStage
  9. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native() @IntrinsicCandidate()
  10. def compose[A](g: (A) ⇒ I): (A) ⇒ Yield[I, O, Either[Throwable, E]]
    Definition Classes
    Function1
    Annotations
    @unspecialized()
  11. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  16. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  17. def recover(in: I, e: Throwable): Yield[I, O, Either[Throwable, E]]

    Called when body throws a non-fatal exception.

    Called when body throws a non-fatal exception.

    in

    the input value that was being processed when the exception occurred

    e

    the non-fatal exception thrown by body

    returns

    a h8io.stages.Yield representing the error outcome

    Definition Classes
    Safe → SafeStage
  18. def skip(): Evolution[I, O, Either[Throwable, E]]

    Returns this stage's Evolution without consuming an input.

    Returns this stage's Evolution without consuming an input.

    Called instead of apply whenever the stage takes part in a run but has nothing to process: the upstream yielded no output, or a binary operator excluded this branch. The evolution must be the one the stage would have returned had it run. Like apply, skip() may perform side effects — a decorator, for instance, may advance or release the inner stage it owns.

    Definition Classes
    Safe → Stage
  19. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  20. def toString(): String
    Definition Classes
    Function1 → AnyRef → Any
  21. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  23. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def ~>[_O, _E >: Either[Throwable, E]](that: Stage[O, _O, _E]): Stage[I, _O, _E]

    Composes this stage with that, feeding this stage's output into it.

    Composes this stage with that, feeding this stage's output into it. See the Composition section above for what happens when there is no output to feed.

    Definition Classes
    Stage
    Annotations
    @inline()

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] ) @Deprecated
    Deprecated

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from SafeStage[I, O, Either[Throwable, E]]

Inherited from Alterator[Stage[I, O, E], I, O, Either[Throwable, E]]

Inherited from Stage[I, O, Either[Throwable, E]]

Inherited from (I) ⇒ Yield[I, O, Either[Throwable, E]]

Inherited from AnyRef

Inherited from Any

Ungrouped