Database connection issues handling on startup


When we try to start an application and a database is not available, the following error is displayed on UI:

Could you please clarify if it is possible to replace this error message with another one without stacktrace?


Have you tried to set cuba.web.productionMode app property to false as the message suggests?


Yes, I tried and “Unexpected error” message was displayed.


Could you please clarify if it is possible to change error description so as to display “DB is unavailable”?
Besides, “Retry” doesn’t help if DB has been started. How can we intercept error if DB is not available on startup and complete the application?

Yes, you can redefine the following messages in your main message pack:

app.initErrorCaption = Unexpected error
app.initErrorMessage = Please contact system administrator
app.initErrorDebugInfoTitle = See details in the server log. Root cause:
app.initErrorExceptionInfoTitle = Exception details:
app.initRetry = Retry

You can create your own AppContextLoader or WebAppContextLoader and use it in web.xml of the core/web blocks, but I strongly DON’T recommend doing it. Better make your database available when it is needed, or just inform your users with proper messages.