onError method

  1. @override
void onError(
  1. FlutterErrorDetails details
)
inherited

Supply an 'error handler' routine to fire when an error occurs. Override if you like to customize error handling.

Implementation

// details.exception, details.stack
/// Override if you like to customize error handling.
// Allow a complete override. gp
//  @mustCallSuper
@override
void onError(FlutterErrorDetails details) {
  // Don't call this routine within itself.
  if (inErrorRoutine) {
    return;
  }
  // In case there's an error in this routine
  inErrorRoutine = true;

  // Call the latest SateX object's error routine
  // Possibly the error occurred there.
  onStateError(details);

  if (AppErrorHandler.presentError) {
    // Logs 'every' error as the error count is reset.
    logErrorDetails(details);
  }

  try {
    // Call the App's error handler.
    AppErrorHandler.flutterExceptionHandler?.call(details);
  } catch (e, stack) {
    recordException(e, stack);
  }

  // Always test if there was an error in the error handler
  // Include it in the error reporting as well.
  if (hasError) {
    _onErrorInHandler();
  }

  try {
    // If an external handler was provided
    if (errorHandler != null) {
      onErrorHandler(details);
    }
    // If there's any 'inline function' error handler.
    // It takes last precedence.
    inError?.call(details);
    inErrorHandler?.call(details);
  } catch (e, stack) {
    recordException(e, stack);
  }
  // Always test if there was an error in the error handler
  // Include it in the error reporting as well.
  if (hasError) {
    _onErrorInHandler();
  }
  inErrorRoutine = false;
}