ioGuard<T> static method

FutureResult<T, IoError> ioGuard<T>(
  1. Future<T> fn()
)

Implementation

static FutureResult<T, IoError> ioGuard<T>(Future<T> Function() fn) async {
  try {
    return Ok(await fn());
  } on IOException catch (e) {
    return Err(IoError.ioException(e));
  } catch (e) {
    return Err(IoError.unknown(e));
  }
}