Closed kaihenkel closed 4 years ago
Hi, in your example you can change:
throw new ResponseStatusException(HttpStatus.I_AM_A_TEAPOT);
to
return new HttpResponse(HttpStatus.I_AM_A_TEAPOT);
If you want to redirect to some error page just return a response with FOUND
status and header Location: /url/to/error/page
hi, thank you for you're quick response! I will try that first thing when I am back at the office on Monday. I will comment my results here. best regards, Kai Henkel
Hi Again,
As promised I reviewed you're solution this morning and it is actually not what i was looking for. In you're solution I am redirecting the customer to the error page.
I was looking for a solution that utilizes the spring-error handling with the customizable error-page.
I updated my example project to illustrate the problem further.
Ok, so I implemented an custom-spring filter that throws the a ResponseStatusException. As it turns out, this also leads to an internal server error response, event though I set another status code within the exception. So, its not a problem with you're proxy but a spring one.
Therefore I am closing this issue. However, for everyone interested, if I find a working solution I will update my example project accordingly.
Thank you for you're help!
Hi, Yes, I tried that, the problem is not within the charon-framework but that exceptions thrown within the filter/interceptors generally won't be handled by the spring-error eco system.
However, i have found a solution and updated my example with a working solution.
Thanks again for you're support.
I would like to use the default error handling from spring boot when throwing an from within an custom interceptor. This will display the spring-boot whitelabel error page, which I will be using. The main Problem is, that even though i throw an ResponseStatusException the response-status is allways 500.
I have created a small demo-project that demonstrates the problem here.
Anny Suggestions how I could handle this problem?