runWithAsyncErrorCapture<T> static method
Run a function with async error capture (Zone-based)
Implementation
static T runWithAsyncErrorCapture<T>(
T Function() callback, {
AsyncErrorCaptureConfig? config,
}) {
final finalConfig =
config ?? instance._config ?? const AsyncErrorCaptureConfig();
if (!finalConfig.captureGlobalZoneErrors) {
// If zone capture is disabled, just run the callback
ObslyLogger.debug(
'Zone-based error capture disabled, running callback directly');
return callback();
}
return runZonedGuarded(
callback,
(error, stackTrace) =>
_handleZoneError(error, stackTrace, finalConfig),
) ??
(null as T);
}