spring-bootvaadin14

Vaadin catch "Could not navigate to 'route' and redirect to existing route


I am doing a Vaadin App that has three Views, and whenever the users enters an unknown URL he sees this page:

Could not navigate to 'stackoverflow' Reason: Couldn't find route for 'stackoverflow'

Available routes: app login logout

This detailed message is only shown when running in development mode. I want to define a route instead of showing this page, how to do it? Like whenever this messgage is shown it should just swallow it and redirect to an existing route.


Solution

  • What you're seeing is the default "not found" error handler. You can define your own error handler by creating a UI component (e.g. VerticalLayout) subclass that implements HasErrorParameter<NotFoundException>. Flow will automatically that class from the application in the same way that it picks up @Route annotated classes.