guardResult<S> function

Result<S, Object> guardResult<S>(
  1. Result<S, Object> func()
)

Result unwrapping version of guard. Where func returns an Result, but can still throw.

Implementation

@pragma("vm:prefer-inline")
Result<S, Object> guardResult<S>(Result<S, Object> Function() func) {
  try {
    return func();
  } catch (e) {
    return Err(e);
  }
}