Vaadin custom error message
The Vaadin web framework displays a red error alert for any uncaught exceptions:
Internal error
Please notify the administrator
...
The Vaadin documentation describes how to set a custom error handler.
When I provide a custom error handler, the default red error alert still shows up. When the user dismisses that error alert, then the custom error alert appears. I would like to only show the custom error alert. How can one disable the default "Internal error" alert?
Below is the overridden terminalError method of my vaadin Application class:
@Override public void terminalError(Terminal.ErrorEvent event) {
// Call the default implementation.
super.terminalError(event);
// Some custom behaviour.
if (getMainWindow() != null) {
getMainWindow().showNotification(
"An unchecked exception occured!",
event.开发者_如何学编程getThrowable().toString(),
Notification.TYPE_ERROR_MESSAGE);
} }
You have to define a static method called getSystemMessages in your Application class, which will return a CustomizedSystemMessages object. If you call setInternalErrorNotificationEnabled method with false parameter "internal error" will disappear. This way you can disable Vaadin's built-in notification messages for other error types as well.
You can provide a url by calling setInternalErrorURL so that Vaadin will redirect your page to that url whenever internal error occurs. You can display your error message in that page. This page could be a Vaadin window as well.
Do both actions happens because you call super.terminalError(event)
?
Or do you have to clear the component error that is set in this method?
Paul is right : you have to remove the call to the super.
To work, I did the following in my subclass of Application :
setErrorHandler(this); // dont know why it's doesn't work without this instruction.
and I override the terminalError method without the call to super.terminalError()
.
Regards, Éric
精彩评论