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;

  // The base Error Handler
  super.onError(details);

  try {
    // Call the App's error handler.
    App.onError(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();
  }

  // If there's any 'inline function' error handler.
  // It takes last precedence.
  if (inErrorHandler != null || inError != null) {
    try {
      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;
}