Errorhandling for Button, bug or feature?


I discovered something strange today. I have a button in which an exception could be thrown. The errorhandler is in a surrounding component.

When I click the button, the exception is thrown.
If I assign a shortcut to this button and use the shortcut, my custom errorhandler is NOT called.

Is this a bug or a feature?

See sample code below.


import com.vaadin.event.ShortcutAction;
import com.vaadin.server.DefaultErrorHandler;
import com.vaadin.ui.Button;
import com.vaadin.ui.CustomComponent;

public class Form extends CustomComponent {
  public Form() {
    Button button = new Button("Click", new Button.ClickListener() {
      public void buttonClick(Button.ClickEvent clickEvent) {
        throw new RuntimeException("Button clicked");
    setErrorHandler(new DefaultErrorHandler() {
      public void error(com.vaadin.server.ErrorEvent event) {
        System.out.println("In custom error handler of Form object");

Sounds like a bug

It’s an admittedly weird side effect of the fact that keyboard shortcuts are actually handled by the UI (or Window), not the Button itself. The handling code should probably still be changed to invoke the error handler of the logically originating component.