Change the insertion order of `ExceptionHandlerFunction`
See original GitHub issueLet’s look at the following example:
1: ServerBuilder sb = ...
2: sb.annotatedService()
3: .decorator(delegate -> (ctx, req) -> {
4: return delegate.serve(ctx, req).mapHeaders(headers -> {
5: System.err.println("This isn't called.");
6: return headers;
7: });
8: })
9: .exceptionHandlers((ctx, req, cause) -> HttpResponse.of(200))
10: .build(new Object() {
11: @Get("/foo")
12: public HttpResponse foo(String foo) {
13: throw new IllegalArgumentException();
14: }
15: });
The fifth line is not called because the specified exception handler is attached before the decorator so mapHeaders is not applied:
A request flow:
request -> ExceptionHandlerFunction -> decorator -> Request(Response)Converter -> Annotated service
The reason why the ExceptionHandlerFunction is located before the decorator is that we wanted to catch the exception raised in the decorator.
However, it has this bypassing problem, and also ExceptionHandlerFunction is not installed with the Request(Response)Converter at the same level which users expect so.
Issue Analytics
- State:
- Created a year ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Java Global Exception Handler - Baeldung
Learn how to globally handle all uncaught exceptions in your Java application.
Read more >11 PL/SQL Error Handling
11 PL/SQL Error Handling. This chapter explains how to handle PL/SQL compile-time warnings and PL/SQL runtime errors. The latter are called exceptions.
Read more >Hashmap + Insertion Order - java - Stack Overflow
That's just what happens to occur with the version you're using and the values you're inserting. There's no guarantee it will continue to...
Read more >Java Catch Multiple Exceptions, Rethrow Exception
Note that this analysis is disabled if you change the catch block argument. Further Reading: Exception Handling in Java.
Read more >PHP Exception Handling - W3Schools
The code execution will switch to a predefined (custom) exception handler function; Depending on the situation, the handler may then resume the execution...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Thanks for your opinion. 😄
Yeah, it could be a breaking change so we might be able to change that in 2.0 Or, we can fix it right now if everyone thinks that it’s a bug. 😆
Agree with the direction. I was quite confused with the differentiation between
ServerErrorHandlerandExceptionHandlerFunctionin the past and the change will make their roles more clear.I was just worried that this can be a breaking change. cc. @ghkim3221