Task<S, F>.attempt constructor

Task<S, F>.attempt({
  1. required FutureOr<S> run(),
  2. required F handle(
    1. Object e
    ),
})

Runs a function that may throw, catching a throw as a Failure.

The failure holds handle(e), the exception and the stack trace. If handle itself throws, the task completes with that error.

Implementation

Task.attempt({
  required FutureOr<S> Function() run,
  required F Function(Object e) handle,
}) : this._(t.Task.attempt(run: run, handle: handle));