chainTryCatchK<L, R, R2> function

TaskEither<L, R2> Function(TaskEither<L, R> taskEither) chainTryCatchK<L, R, R2>(
  1. FutureOr<R2> task(
    1. R value
    ),
  2. L onError(
    1. dynamic err,
    2. StackTrace stackTrace
    )
)

A chainable variant of tryCatchK.

expect(
  await right('hello').chain(chainTryCatchK(
    (s) => '$s world',
    (err, stack) => 'fail',
  ))(),
  E.right('hello world'),
);
expect(
  await right('hello').chain(chainTryCatchK(
    (s) => throw 'error',
    (err, stack) => 'fail',
  ))(),
  E.left('fail'),
);

Implementation

TaskEither<L, R2> Function(
  TaskEither<L, R> taskEither,
) chainTryCatchK<L, R, R2>(
  FutureOr<R2> Function(R value) task,
  L Function(dynamic err, StackTrace stackTrace) onError,
) =>
    flatMap(tryCatchK(task, onError));