match<E2, B> method

ZIO<R, E2, B> match<E2, B>(
  1. ZIO<R, E2, B> onError(
    1. E _
    ),
  2. ZIO<R, E2, B> onSuccess(
    1. A _
    )
)

Reduce the success and error values of this ZIO using the given functions.

Implementation

ZIO<R, E2, B> match<E2, B>(
  ZIO<R, E2, B> Function(E _) onError,
  ZIO<R, E2, B> Function(A _) onSuccess,
) =>
    ZIO.from(
      (ctx) => unsafeRun(ctx).then(
        (ea) => ea._matchExitFOr(
          (e) => onError(e).unsafeRun(ctx),
          (a) => onSuccess(a).unsafeRun(ctx),
        ),
      ),
    );