onError method
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.
// @mustCallSuper // Allow a complete override. gp
@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.
// _errorHandler?.flutteryExceptionHandler?.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 handler not explicitly passed as a parameter
var callOriginal = _errorHandler?.errorHandler == null;
if (!callOriginal) {
_errorHandler?.errorHandler?.call(details);
}
// Any 'on' Error handler
onErrorHandler(details);
// It would appear it was not overwritten
callOriginal = callOriginal && !_errorHandlerOverridden;
// No 'in-line' version
callOriginal = callOriginal && inErrorHandler == null;
if (callOriginal) {
_errorHandler?.oldOnError?.call(details);
} else {
// 'inline function' error handler, takes last precedence.
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();
}
// If in testing, after the supplied handler, call its Error handler
if (_errorHandler?.errorHandler != null &&
WidgetsBinding.instance is! WidgetsFlutterBinding) {
_errorHandler?.oldOnError?.call(details);
}
inErrorRoutine = false;
}