onError method
Called whenever an error
occurs and notifies ObserverController.onError.
In debug mode, onError throws a ControllerUnhandledErrorException for improved visibility.
In release mode, onError does not throw and will instead only report the error to ObserverController.onError.
Note: super.onError
should always be called last.
@override
void onError(Object error, StackTrace stackTrace) {
// Custom onError logic goes here
// Always call super.onError with the current error and stackTrace
super.onError(error, stackTrace);
}
Implementation
@protected
@mustCallSuper
void onError(Object error, StackTrace stackTrace) {
// ignore: invalid_use_of_protected_member
Controller.observer.onError(this, error, stackTrace);
assert(() {
throw ControllerUnhandledErrorException(this, error, stackTrace);
}());
}