tryCatchAsync<T, E> static method
Constructs a new Result from a function that might throw.
Implementation
static Future<Result<T, E>> tryCatchAsync<T, E>(
Future<T> Function() fn,
E Function(Object error) onError,
) async {
try {
return Ok(await fn());
} catch (e) {
return Err(onError(e));
}
}