Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Error handler does not navigate to the error page on the first request
It seems there is a problem with how Vaadin uses error handlers. Here are two scenarios to illustrate the issue:
1. The Vaadin session exists for the user. The user may be on the Home page, for example. Next, the user attempts to go to a specific URL in the application and it results in an exception that is caught by a registered error handler that navigates to the error page with the error details. Everyting works fine, the user sees a friendly error message with explanation what happened/what to do next.
2. The user is not on any of the application pages therefore there is no Vaadin session. The user enters a URL that takes him to one of the application pages. In the process, a session is initialized and an error handler gets registered. Then in the further process of the request, an exception is thrown, same as in the scenario #1. It is caught by the registered error handler which attempts to navigate to the error page to show error information to the user. This time the navigation to the error page fails and the user is presented with very "user-unfriendly" error information from the application server itself with full stack trace.
It seems in the second scenario, the lifecycle of the request processing is different from the first scenario when the session already exists. In the first scenario, the exception is caught earlier and not propagated outside of the request processing. In the second, while caught and processed by the custom handler, it is done in the catch clause of the VaadinService.handleRequest method that returns the exception back to the servlet container that, in turn, generates the standard error message with stack trace into the response.
In our case, it is essential to process requests that do not have an existing session (the app does not have a login/home page and users navigate to the pages they need by URL from another app) but we can't be showing the user "unfriendly" error messages that include stack trace. We always want them to see the application error page regardless of where and when errors happen in the processing.
Any help with this issue is greatly appreciated! Thank you!
It seems there is a bug submitted for this issue:
Created two and a half years ago... I guess we are out of luck with this :-(