IOOption<R>.tryCatch constructor

IOOption<R>.tryCatch(
  1. R run()
)

Converts a function that may throw to a function that never throws but returns a Option instead.

Used to handle synchronous computations that may throw using Option.

Implementation

factory IOOption.tryCatch(R Function() run) => IOOption<R>(() {
      try {
        return Option.of(run());
      } catch (_) {
        return const Option.none();
      }
    });