tryCatch<S, C, L, R> function
StateReaderTaskEither<S, C, L, R>
tryCatch<S, C, L, R>(
- FutureOr<
R> task(), - L onError(
- dynamic err,
- 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))),
));