runGuarded<R> static method

R? runGuarded<R>(
  1. R body(),
  2. BugseeGenericErrorCallback errorCallback
)

Wraps specified function with automatic errors and exceptions interception (using runZonedGuarded() with onError handler).

Implementation

static R? runGuarded<R>(
    R Function() body, BugseeGenericErrorCallback errorCallback) {
  return runZonedGuarded<R>(() {
    return body();
  }, (error, stackTrace) async {
    await _exceptionHandler?.logException(error, false, stackTrace);
    await errorCallback(error, stackTrace);
  });
}