guardCallback method
Wraps a synchronous callback, rethrowing the normalized error to its caller.
Reports the error automatically and updates the fallback in a microtask.
Implementation
VoidCallback guardCallback(
VoidCallback action, {
String? source,
FutureOr<void> Function(BaseException e)? onError,
}) {
return () {
try {
action();
} catch (e, s) {
final normalized = _normalize(e, s, source: source);
scheduleMicrotask(() => _captureAutomatic(normalized, onError));
Error.throwWithStackTrace(normalized, s);
}
};
}