Proper error handling

Information about error handling is quite scattered all over the internet. I would like to have a global error handler and do it in proper way.

I have registered a session listener in my servlet. In that listener, I registered a DefaultErrorHandler. But what am I supposed to do now? How can I hide the stacktrace (which is a security issue) and show some reasonable UI? Or should I have a parent UI class with registration of ErrorHandler?

@WebServlet(urlPatterns = "/*")
@VaadinServletConfiguration(ui = MyUI.class, productionMode = true)
public class MyUIServlet extends VaadinCDIServlet {

    @Override
    protected void servletInitialized() throws ServletException {
        getService().addSessionInitListener(new ErrorHandlerSessionListener());
    }

}
[/code][code]
public class ErrorHandlerSessionListener implements SessionInitListener {

    @Override
    public void sessionInit(SessionInitEvent event) throws ServiceException {
        VaadinSession session = event.getSession();
        session.setErrorHandler(new DefaultErrorHandler() {
            @Override
            public void error(ErrorEvent event) {
                Throwable relevantThrowable = DefaultErrorHandler.findRelevantThrowable(event.getThrowable());
                //TODO
            }
        });
    }
}

I think my answer to your question here should solve most of your problems:
https://vaadin.com/forum#!/thread/1383731/10920018

Perfect answer Marius. I actaully think Vaadin should do what you suggested by default if it is in production mode: just print the stacktrace to log and so generic error notification in the UI.

I created
an issue for such an enhancement
.

cheers,
matti