toOptional method

Optional<T> toOptional()

Implementation

Optional<T> toOptional() {
  try {
    return Optional.of(_supplier.get());
  } on Exception catch (e) {
    return Optional.of(_recoveries[e.runtimeType]) // @formatter:off
        .filter((recovery) => notNull(e))
        .map((recovery) => recovery(e)); // @formatter:on
  }
}