Own DefaultErrorHandler not working with com.vaadin.navigator.View.enter


I have my own MyErrorHandler that extend DefaultErrorHandler. I set him into UI.
In mostly use cases it works for whole application BUT when happand some RuntimeException inside “com.vaadin.navigator.View.enter(ViewChangeEvent)” method then MyErrorHandler don’t handle a exception. Exception is processed by DefaultErrorHandler. It cause gray screen with stack trace - if some else View is shown befoce then view is rendered (logic is not still processed).

I use MyErrorHandler for handling ValidationExceptions (runtime exception) from Hibernate for example.
I use “com.vaadin.navigator.View.enter(ViewChangeEvent)” for checking permissions, login, etc…

Did i set MyErrorHandler wrongly or it is there some else issue?

Thank you alot.


PS: Vaadin version - 7.1.11

public class MyUI extends UI {

    protected void init(VaadinRequest request) {
        // init error handling
        setErrorHandler(new MyErrorHandler());

your code
}catch (Exception e){
   UI.getCurrent().getErrorHandler().error(new com.vaadin.server.ErrorEvent(e));

Normaly i try to avoid catching “Exception” but this is actually nice :o).

Thanks you.

Could you confirm whether this only occurs when a new page is loaded (and a new UI created) and the view that is entered throws?

When a new UI is created, it tries to navigate to the requested location if a navigator was added in init(). The problem is that if that navigation fails, no error handler is invoked; the exception propagates straight to the servlet container, giving the ugly stack trace. The same thing happens if, for instance, your UI.init itself throws. This is certainly not optimal, but it’s not trivial to fix, either - it might not be safe to call the UI’s error handler before the UI is completely initialized.


Yes. I can. It’s exactly as you type. You are right.

I am newbie in Vaadin. I noticed the View interface as way to do something when user enter on page / screen. So i for example load some data from database and set them on screen (inside enter() method).

Do exist some else way to handle action when user enter on screen?

For me sound logic that a lot of programmers need this and they have to somehow handle runtime exception from hibernate api (for example). And i think that they don’t wanna that their app drop after that (not whole app).

Sorry for late answer.

Yes, this is indeed something that should be fixed in Vaadin itself; it’s just not completely straightforward to do. Opened
ticket #13467

Still happening in Vaadin 7.5.
Exceptoins thrown during initial Navigator.navigateTo call DO NOT get caught by ErrorHandler.

Still happening in Vaadin 7.6

I have also the same problem :

Exceptions that are thrown during initial Navigator.navigateTo call do not get caught by ErrorHandler.
After this, the application could not be used at all (no menu)

I had a try catch around the Navigator.navigateTo to solve the problem, but it should be fixed by another way.