title: Central error handling in Vaadin
body: <p>I want the framework to catch every uncaught exception and show an appropriate notification message.</p>
  
  <p>Therefore I set a custom <code>ErrorHandler</code> in my UI like this (inspired by the "Book of Vaadin": <a href="https://vaadin.com/book/-/page/application.errors.html" rel="nofollow">https://vaadin.com/book/-/page/application.errors.html</a>):</p>
  
  <pre><code>public abstract class MyUI extends UI {
  
      @Override
      protected void init(final VaadinRequest request) {
          setErrorHandler(new DefaultErrorHandler() {
              @Override
              public void error(final com.vaadin.server.ErrorEvent event) {
                  Throwable error = event.getThrowable();
                  Notification.show(error.getLocalizedMessage(), Notification.Type.ERROR_MESSAGE);
              }
          });
      }
  }
  </code></pre>
  
  <p>But it is not executed when I provoke an error on loading from backend. Instead the form is shown incompletely, and when i reload the page (F5) I get an exception view like the one I know from Tomcat's general exception handlers.</p>
  
  <p>Is it wrong as I set the <code>ErrorHandler</code>? Is there a better way?</p>
  
  <p>I'm using Glassfish 4 and Vaadin 7.</p>