guardAsync<S> function

FutureResult<S, Object> guardAsync<S>(
  1. Future<S> func()
)

Async version of guard

Implementation

@pragma("vm:prefer-inline")
FutureResult<S, Object> guardAsync<S>(Future<S> Function() func) async {
  assert(S is! Result, "Use guardAsyncResult instead");
  try {
    return Ok(await func());
  } catch (e) {
    return Err(e);
  }
}