Closed xtremebiker closed 7 years ago
Understood -> this part of JHipster isn't very clear, let me "handle" this :-)
OK so this part of JHipster is much worse than I thought!!
Anyway: that's bad, it takes some time to fix (as i18n is huge now), and I know what to do -> I should have some time this week (I have a 7 hour flight on Thursday), so I'm assigning this to myself.
There are other standard Spring exceptions that we override : https://github.com/spring-projects/spring-framework/blob/a0bce618c2f51d8af1fc00ee2c3868ba2c8e0045/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java#L106 We should probably do something for them also. Also, I propose to use rfc7807 application/problem+json errors. I believe they should work well with our front-end.
After some digging, I think we should remove our ExceptionHandler
beans and use a global ErrorAttributes
instead. I'll try something asap.
Overview of the issue
The generated ExceptionTranslator catches the
MethodArgumentNotValidException
and theCustomParameterizedException
, butMissingServletRequestPartException
andMissingServletRequestParameterException
should as well be caught and treated to return bad request codes.Reproduce the error
Created a new REST endpoint to display entity field suggestions with this signature:
Then created a new integration test that should return 400 since the required
field
parameter is missing:But the test fails as the endpoint returns a 500 response instead of 400. That's because the exception is caught by the standard processor:
Suggest a Fix
Adding this in the
ExceptionTranslator
solved it:JHipster Version(s)
4.4.1