File tree Expand file tree Collapse file tree
flow-server/src/main/java/com/vaadin/flow/internal
flow-tests/test-root-context/src
main/java/com/vaadin/flow/uitest/ui
test/java/com/vaadin/flow/uitest/ui Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3333import com .vaadin .flow .function .SerializableConsumer ;
3434import com .vaadin .flow .internal .change .NodeChange ;
3535import com .vaadin .flow .internal .nodefeature .NodeFeature ;
36+ import com .vaadin .flow .server .DefaultErrorHandler ;
37+ import com .vaadin .flow .server .ErrorEvent ;
3638import com .vaadin .flow .server .VaadinSession ;
3739import com .vaadin .flow .server .communication .UidlWriter ;
3840import com .vaadin .flow .shared .Registration ;
@@ -387,9 +389,20 @@ public void runExecutionsBeforeClientResponse() {
387389 }
388390 callbacks .stream ().filter (entry -> entry .canExecute (getUI ()))
389391 .forEach (entry -> {
390- ExecutionContext context = new ExecutionContext (getUI (),
391- entry .getStateNode ().isClientSideInitialized ());
392- entry .getExecution ().accept (context );
392+ try {
393+ ExecutionContext context = new ExecutionContext (
394+ getUI (), entry .getStateNode ()
395+ .isClientSideInitialized ());
396+ entry .getExecution ().accept (context );
397+ } catch (Exception e ) {
398+ if (getUI ().getSession ().getErrorHandler ()
399+ .getClass ()
400+ .equals (DefaultErrorHandler .class )) {
401+ throw e ;
402+ }
403+ getUI ().getSession ().getErrorHandler ()
404+ .error (new ErrorEvent (e ));
405+ }
393406 });
394407 }
395408 }
Original file line number Diff line number Diff line change @@ -11,6 +11,15 @@ public ErrorHandlingView() {
1111 throw new IllegalStateException (
1212 "Intentional fail in click handler" );
1313 }));
14+ add (createButton ("Throw exception in beforeClientResponse" ,
15+ "clientResponseButton" , e -> {
16+ e .getSource ().getUI ().get ().getInternals ().getStateTree ()
17+ .beforeClientResponse (getElement ().getNode (),
18+ executionContext -> {
19+ throw new IllegalStateException (
20+ "Intentional fail in beforeClientResponse" );
21+ });
22+ }));
1423 }
1524
1625}
Original file line number Diff line number Diff line change @@ -17,4 +17,15 @@ public void exceptionInClickHandlerDoesNotCauseInternalError() {
1717 "An error occurred: java.lang.IllegalStateException: Intentional fail in click handler" );
1818 }
1919
20+ @ Test
21+ public void exceptionInBeforeClientResponseDoesNotCauseInternalError () {
22+ open ();
23+ $ (NativeButtonElement .class ).id ("clientResponseButton" ).click ();
24+
25+ assertNoSystemErrors ();
26+
27+ assertErrorReported (
28+ "An error occurred: java.lang.IllegalStateException: Intentional fail in beforeClientResponse" );
29+ }
30+
2031}
You can’t perform that action at this time.
0 commit comments