vaadin / portlet

Portlet support for Vaadin Flow
https://vaadin.com
Other
2 stars 3 forks source link

Errors from embedded Flow web components are not visible in the UI #156

Closed pleku closed 4 years ago

pleku commented 5 years ago

When exporting a Flow component as a web component and embedding it into a page and there is an error on the server side, there is nothing visible in the UI for this, it just fails and you don't have any idea what has happened.

There should be at least in development mode a clear indication (visible error dialog) in the UI that something has failed. For production mode it might not be desired to get this behavior (at least out-of-the-box), so maybe it should be configurable. It is another thing should the default be different between development and production mode.

pleku commented 5 years ago

The issue also applies for Vaadin portlets.

pleku commented 5 years ago

The code to call to show an error on the client is https://github.com/vaadin/flow/blob/master/flow-server/src/main/java/com/vaadin/flow/server/VaadinService.java#L1718

pleku commented 5 years ago

Acceptance Criteria

ujoni commented 5 years ago

It seems that vanilla Vaadin, embedded Vaadin, and portlet Vaadin behave exactly the same way. The given example

        Button button = new Button("Click me",
                event -> {
                    throw new RuntimeException("This is very bad!");
                });

Never causes anything to be shown in the browser. And error is logged in the server, but that is all. This is due to the catch-all in

    private void handleInvocationData(UI ui, JsonObject invocationJson) {
        // some code omitted
        try {
            Optional<Runnable> handle = handler.handle(ui, invocationJson);
            assert !handle.isPresent() : "RPC handler "
                    + handler.getClass().getName()
                    + " returned a Runnable even though it shouldn't";
        } catch (Throwable throwable) {
            ui.getSession().getErrorHandler().error(new ErrorEvent(throwable));
        }
    }

The default ErrorHandler does nothing but logs the errors. Nothing will be shown on the client-side. If that line is removed, the error naturally bubbles to VaadinService but then a "an internal error occurred and we are very sorry!" kinda box appears - not very helpful.

I am not sure what is supposed to happen when an exception is throws in an RPC request,

denis-anisimov commented 5 years ago

Right, I've just checked the skeleton-starter. It doesn't show anything in the browser when I click on the button and the listener throws an exception. But since I'm running it in IDE I'm able to see the exception in the console. In portals case I don't have the console visible if I'm not aware about that...... But I would say there should be an error shown in the browser even in plain web application about the error. Though it's not that important for web app. For embedded apps it's important. I'm pretty sure we show the error box in the browser in some cases. But what the cases are : I can't say now. So it may be has some sense to do back eng: check this error message dialog on the client side and realize when it's shown. That's worth to change in Flow generally. But I'm afraid it will be far away from the good UI in portlets: there can be many portlets on the page and it's worth to show the error message somehow attached to the portlet component and not for the whole page.

joheriks commented 4 years ago

Components embedded in Vaadin Portlets currently show server-side exceptions in the browser, while for standard Vaadin and embedded components we assume that such exception are readily visible in IDE console.