Managing server errors
JHipster has first-class support for error handling: it provides error pages and custom mechanisms to handle both business and technical errors on the server-side.
Error pages
JHipster generates a Single-Page Application (SPA), but it still requires custom error pages for people who do not (or cannot) access the application.
Dynamic error pages
JHipster provides a generic error page, which is a Thymeleaf template, located at src/main/resources/templates/error.html
.
This page will display the server-side error message, for example if the user tried to access a non-existing page, it will display a 404 error, telling the user that the page wasn’t found.
Static 404 error page
JHipster provides a specific, static 404 error page located at src/main/webapp/404.html
. By default, this page isn’t used by JHipster: it is here for projects using a proxy before JHipster (Apache/NGinx/etc.), so that the proxy can also display a 404 error page, even if the JHipster application isn’t available.
It needs to be specifically configured on the front-end proxy.
API errors
To handle Spring MVC REST errors, JHipster uses Zalando’s Problem Spring Web library, in order to provide rich, JSON-based error messages.
In order to help the end-user, for each known problem this library will provide a link to a specific error page, that will give more details. Those links are configured in the ErrorConstants
class, and point by default to this website. In your application, you should customize those links, and point them to your own API documentation.
Here are the available error links: