runCatching<R> method

  1. @visibleForTesting
  2. @protected
  3. @override
FutureOr<R?> runCatching<R>(
  1. FutureOr<R?> block(), {
  2. FutureOr<R?> onSuccess(
    1. R data
    )?,
  3. FutureOr<R?> onFailure(
    1. Object e,
    2. StackTrace s
    )?,
  4. bool ignoreSkipError = true,
  5. int slowlyMs = 0,
  6. Object? debounceTag,
  7. Object? throttleTag,
  8. Object? mutexTag,
})
override

run and catch error, then putError

ignoreSkipError same as update((o)=>null) ref skpIf/skpNull

Implementation

@visibleForTesting
@protected
@override
FutureOr<R?> runCatching<R>(
  FutureOr<R?> Function() block, {
  FutureOr<R?> Function(R data)? onSuccess,
  FutureOr<R?> Function(Object e, StackTrace s)? onFailure,
  bool ignoreSkipError = true,
  int slowlyMs = 0,
  Object? debounceTag,
  Object? throttleTag,
  Object? mutexTag,
}) => super.runCatching(
  block,
  onSuccess: onSuccess,
  onFailure: (e, s) {
    if (e is SkipError && ignoreSkipError) {
      logger(
        'SKIPPED: ${e.msg}',
        logExtra: logExtra,
        stackTrace: e.stackTrace,
      );
      return null;
    }
    final fun = onFailure ?? (e, s) => logger('$e\n$s', logExtra: logExtra);
    return fun.call(e, s);
  },
  ignoreSkipError: false,
  slowlyMs: slowlyMs,
  debounceTag: debounceTag,
  throttleTag: throttleTag,
  mutexTag: mutexTag,
);