panter/org.vaadin.mvp — Issue #7: exception inside the event bus handler can not be caught by vaadin application
Author: fbird
Created: 2012-02-24 05:26:24+00:00
State: open

Hello, I met a problem that vaadin application can't catch the exception happened in the event bus handler, so the application is hard to have a common method to handle the exception happened inside the handler, I saw that EventBusHandler will catch the exception thrown by the handler and won't throw out but just log the error.

So if we want to let user know that there are some errors happened when doing some operation, the only way to do this is to add try catch for each handler's invoke method, such as:

public void onGotoSearchPage() {
try {
...
loadInitData(); // if exception thrown here.
...
view.showSearchPage();
} catch (Exception e) {
view.showOperationFailedWindow(getErrorMsg(e));
}
}
}

just like the example above, onGotoSearchPage() is the gotoSearchPage event's handle method, if exception thrown when loadInitData(), and we need to add try catch around it to handler the exception, but this kind of operation are very common here, so we need to add the try catch for each handle method.

And a better way to do this is to let the exception thrown out to the application, and the application can commonly handle this kind of exception.