catchResultAsync<T, E> function

Future<Result<T, E>> catchResultAsync<T, E>(
  1. FutureOr<Result<T, E>> fn()
)

Executes the given function asynchronously, returning the returned Result value.

If a ResultError is thrown during the execution of the given function, which occurs when an Err() value is unwrapped, the Err() that was unwrapped will be returned.

Behaves identically to catchResult but async, returning Future<Result<T, E>> rather than Result<T, E>.

See also: Result.call()

Implementation

Future<Result<T, E>> catchResultAsync<T, E>(FutureOr<Result<T, E>> Function() fn) async {
	try { return await fn(); }
	catch (error) { return _handleResultError(error); }
}