Exception Handling
How exceptions are handled when using Swing Kit, and how to configure it.
By default, any exception not handled by the remote View, is handled by Swing.
As a default behaviour, Swing shows the exception in a JOptionPane
.
This behaviour can be configured to catch any Vaadin exceptions from Swing, directly.
Manually Handle Vaadin Exceptions
A custom handler for the exception can be used after disabling the default behaviour with the following:
vaadinPanel.disableDefaultExceptionHandler();
Add a custom exception handler by adding the following:
vaadinPanel.addEventListener(EventType.EXCEPTION, event -> {
// Print to standard output the exception content
System.out.println(event.getParams().get("content"));
});
Notice, that the event contains only String
values instead of the original Exception
.
This is to avoid serialization errors due to different classpaths from the Vaadin application and the Swing application.