Skip to main content
Version: 2.x

Recovering From Errors

When a ZIO effect fails, we have several strategies for bringing it back to a successful result. Some operators work on the typed error channel; others reach into the full Cause graph to handle defects and interruptions as well.

  1. Catching recovers from typed failures, defects, interruptions, and the full Cause graph using operators such as catchAll, catchSome, catchAllCause, and catchAllDefect.
  2. Fallback provides an alternative effect or value when an effect fails, using orElse, orElseFail, orElseSucceed, and related combinators.
  3. Folding handles both success and failure in one step with fold, foldZIO, foldCause, and foldCauseZIO — the primitive all other ZIO error operators build on.
  4. Retrying re-runs a failing effect according to a Schedule policy, with configurable delays, attempt limits, and fallback strategies.
  5. Timing Out bounds effect execution time with timeout combinators that safely interrupt the effect and optionally convert the result to a typed failure.
  6. Sandboxing exposes the full Cause graph — including defects and interruptions — using sandbox, unsandbox, and sandboxWith, so any recovery operator can reach them.