catchError<E2> method

ZIO<R, E2, A> catchError<E2>(
  1. ZIO<R, E2, A> f(
    1. E _
    )
)

Catch any errors that may occur on this ZIO. The result will be replaced by executing the ZIO resulting from the given function.

Implementation

ZIO<R, E2, A> catchError<E2>(
  ZIO<R, E2, A> Function(E _) f,
) =>
    _mapCauseFOr(
      (ctx, _) =>
          _ is Failure<E> ? f(_.error).unsafeRun(ctx) : Either.left(_.lift()),
    );