ZIO<R, E, A>.tryCatchEnv constructor

ZIO<R, E, A>.tryCatchEnv(
  1. FutureOr<A> f(
    1. R env
    ),
  2. E onError(
    1. dynamic error,
    2. StackTrace stackTrace
    )
)

A variant of ZIO.tryCatch that provides the current environment R to the function f.

Implementation

factory ZIO.tryCatchEnv(
  FutureOr<A> Function(R env) f,
  E Function(dynamic error, StackTrace stackTrace) onError,
) =>
    ZIO.from(
      (ctx) => fromThrowable(
        () => f(ctx.env),
        onError: (e, s) => Failure(onError(e, s)),
      ),
    );