runCatching<R> method
FutureOr<R?>
runCatching<R>(
- FutureOr<
R?> block(), { - FutureOr<
R?> onSuccess(- R data
- FutureOr<
R?> onFailure(- Object e,
- StackTrace s
- @Deprecated('removed, set `Logger.root.level = Level.FINE` or lower to print SkipError') bool ignoreSkipError = true,
- int slowlyMs = 0,
- Object? debounceTag,
- Object? throttleTag,
- Object? mutexTag,
override
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,
@Deprecated(
'removed, set `Logger.root.level = Level.FINE` or lower to print SkipError',
)
ignoreSkipError = true,
int slowlyMs = 0,
Object? debounceTag,
Object? throttleTag,
Object? mutexTag,
}) => super.runCatching(
block,
onSuccess: onSuccess,
onFailure: (e, s) {
if (e is SkipError) {
logger(
'SKIPPED: ${e.msg}',
level: e.level,
logExtra: logExtra,
// error: e, // do not log SkipError
stackTrace: e.stackTrace,
);
return null;
}
final fun =
onFailure ??
(e, s) => logger(
'FAILURE: $e',
level: Level.WARNING.value,
logExtra: logExtra,
error: e,
stackTrace: s,
);
return fun.call(e, s);
},
ignoreSkipError: false,
slowlyMs: slowlyMs,
debounceTag: debounceTag,
throttleTag: throttleTag,
mutexTag: mutexTag,
);