Handling Errors
Java
The result is shown in Error Indicator Active.
Error Indicator Active
If the connection to the server is lost, Vaadin application shows a “lost connection” notification and tries to restore the connection. After several retries, an error message is shown. You can customize the messages, timeouts, and the number of reconnect attempts in the ReconnectDialogConfiguration object, which you can access from your UI with getReconnectDialogConfiguration().
System messages are notifications that indicate a major invalid state that usually requires restarting the application. Session timeout is perhaps the most typical such state.
System messages are strings managed in the SystemMessages class.
sessionExpired
The Vaadin session expired. A session expires if no server requests are made during the session timeout period. The session timeout can be configured with the session-timeout parameter in web.xml, as described in .
An unspecified communication problem between the Vaadin Client-Side Engine and the application server. The server may be unavailable or there is some other problem.
authenticationError
This error occurs if 401 (Unauthorized) response to a request is received from the server.
internalError
A serious internal problem, possibly indicating a bug in Vaadin Client-Side Engine or in some custom client-side code.
cookiesDisabled
Informs the user that cookies are disabled in the browser and the application does not work without them.
Each message has four properties: a short caption, the actual message, a URL to which to redirect after displaying the message, and property indicating whether the notification is enabled.
Additional details may be written (in English) to the debug console window described in “Debug Mode and Window”.
You can set the system message provider in the servletInitialized() method of a custom servlet class, for example as follows:
Java
See for information about customizing Vaadin servlets.
Handling events can result in exceptions either in the application logic or in the framework itself, but some of them may not be caught properly by the application. Any such exceptions are eventually caught by the framework. It delegates the exceptions to the DefaultErrorHandler, which displays the error as a component error, that is, with a small red “!” -sign (depending on the theme). If the user hovers the mouse pointer over it, the entire backtrace of the exception is shown in a large tooltip box, as illustrated in Uncaught Exception in Component Error Indicator.
Uncaught Exception in Component Error Indicator
You can customize the default error handling by implementing a custom ErrorHandler and enabling it with setErrorHandler() in any of the components in the component hierarchy, including the UI, or in the VaadinSession object. You can either implement the ErrorHandler or extend the DefaultErrorHandler. In the following example, we modify the behavior of the default handler.
Java
The above example also demonstrates how to dig up the final cause from the cause stack.