-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to convert IllegalArgumentException as an HTTP 400 (Bad Request) response #126
Comments
Hi, please take a look at rapidoid/rapidoid-integration-tests/src/test/java/org/rapidoid/http/CustomizationTest.java Line 110 in 75e5291
|
Hi, that seems to do what I need |
Hi @nmihajlovski ! I'm reopening this because using the |
Hi @nmihajlovski , Thanks for the fast follow-up I tried updating to 5.4.1, I still have the same issue. The errors I throw are not handled by my custom handlers. My POJO controller isn't registered using App.beans, I'm using the |
One more interesting behavior: If before setting up my |
Ok thanks for the follow-up @nmihajlovski I'll close this one then. |
Currently, if we return
null
from a controller, the response is automatically translated to a404 not found
which is very convenient. However for any thrown errors, the response is converted to a 500 internal server error.However, when designing a REST API, it is very common that we want to return a 400 Bad Request because the client request parameters are invalid.
It would be more useful if we could simply throw an IllegalArgumentException and have that exception translated to a 400 Bad Request response.
Maybe there is a convenient mechanism for handling this but I looked at all the documentation and the examples and couldn't find any clues on how to implement this is a nice way.
The text was updated successfully, but these errors were encountered: