Closed mshabarov closed 2 years ago
I've compared the way how the Pluto and Liferay generate the JSON with error information. They do it in the same way:
PortletUidlRequestHandler
handles RPC via getRpcHandler(session).handleRpc(uI, request.getReader(), request);
DefaultPortletErrorHandler
and the following JSON is generated:
for(;;);[{"changes":{},"resources":{},"locales":{},"meta":{"appError":{"caption":"RuntimeException","url":null,"message":"Exception!","details":"Caused by: N/A","querySelector":"[data-portlet-id='_errorhandling_WAR_liferaytestsgeneric_INSTANCE_oshz_']"}},"syncId":-1}]
and written into the response.
writeUidl(uI, stringWriter, false);
generates for(;;);[{"syncId":3,"clientId":3}]
JSON and writes it to the response.The solution I see so far is to take this specific behaviour for Liferay and do not set the smaller that actual length.
When an exception is throws on the server side in a portlet, the
DefaultPortletErrorHandler
intercepts it and generates a response with JSON containing error information. Then, at some point something is trimming the JSON so as it looks like follows:for(;;);[{"changes":{},"resources":
As a result, the error message is not shown in the portlet area.Another problem is that the error box is not shown at all, but instead the error message div is added to the page DOM, instead of portlet shadow DOM.
Minimal reproducible example
liferay-test
branch, and this test: https://github.com/vaadin/portlet/tree/liferay-test/vaadin-portlet-liferay-integration-tests/liferay-tests-generic/src/main/java/com/vaadin/flow/portal/liferay/errorhandlingvaadin-portlet-static
portlet into Liferay container.Expected and actual behavior Expected: the red message box showing the original error text within the portlet content area. Actual: message added to the end of the page with unrelated text:
Versions: