tryOr<T> function

T tryOr<T>(
  1. T worker(),
  2. T onError
)

Implementation

T tryOr<T>(T Function() worker, T onError) {
  try {
    return worker();
  } catch (e) {
    return onError;
  }
}