IOEither<L, R>.tryCatch constructor
IOEither<L, R>.tryCatch (
- R run(),
- L onError(
- Object error,
- StackTrace stackTrace
Converts a Function that may throw to a Function that never throws but returns a Either instead.
Used to handle asynchronous computations that may throw using Either.
Implementation
factory IOEither.tryCatch(R Function() run,
L Function(Object error, StackTrace stackTrace) onError) =>
IOEither<L, R>(() {
try {
return Right<L, R>(run());
} catch (error, stack) {
return Left<L, R>(onError(error, stack));
}
});