tryCatch<S, C, L, R> function

StateReaderTaskEither<S, C, L, R> tryCatch<S, C, L, R>(
  1. FutureOr<R> task(),
  2. L onError(
    1. dynamic err,
    2. StackTrace stackTrace
    )
)

Runs the given task, and returns the result as an Right. If it throws an error, the the error is passed to onError, which determines the Left value.

Implementation

StateReaderTaskEither<S, C, L, R> tryCatch<S, C, L, R>(
  FutureOr<R> Function() task,
  L Function(dynamic err, StackTrace stackTrace) onError,
) =>
    StateReaderTaskEither((s) => ReaderTaskEither(
          (r) => TE.tryCatch(task, onError).p(TE.map((r) => tuple2(r, s))),
        ));