tryCatchK<L, R, T> static method

Either<L, R> Function(T) tryCatchK<L, R, T>(
  1. R run(
    1. T
    ),
  2. L onError(
    1. Object o,
    2. StackTrace s
    )
)

Try to execute run. If no error occurs, then return Right. Otherwise return Left containing the result of onError.

run has one argument, which allows for easier chaining with Either.flatMap.

Implementation

static Either<L, R> Function(T) tryCatchK<L, R, T>(
        R Function(T) run, L Function(Object o, StackTrace s) onError) =>
    (a) => Either.tryCatch(
          () => run(a),
          onError,
        );