guardExceptionAsync<T extends Object?, E extends Exception> static method
Future<Result<T, E> >
guardExceptionAsync<T extends Object?, E extends Exception>(
- Future<
T> asyncBlock()
Executes an asynchronous function, catching only Exception types.
A convenience method that constrains the error type to Exception rather than accepting any Object. Use this when you want Error values to propagate uncaught.
Example:
final result = await Result<String, IOException>.guardExceptionAsync(
() => file.readAsString(),
);
Implementation
static Future<Result<T, E>> guardExceptionAsync<
T extends Object?,
E extends Exception
>(Future<T> Function() asyncBlock) => guardAsync<T, E>(asyncBlock);