Allow HTTP status exceptions to be easily thrown from Controllers [SPR-14895] #19461
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
Uh oh!
There was an error while loading. Please reload this page.
Norris Shelton opened SPR-14895 and commented
There is no way to throw exceptions out of the box. Developers must create exceptions for each HTTP status they want to throw, create exception handlers, etc. It would be much better if basic functionality was included. I created a ResourceException class (probably could have a better name for Spring), a generic controller advice (maybe call it something specific to the exception class). If they are included in the SpringFramework, it would be backwards compatible and it would be very easy to throw an exception. An example usage would be:
throw new ResourceException(HttpStatus.BAD_REQUEST, "Missing the user first name");
Affects: 4.3.4
Reference URL: http://stackoverflow.com/questions/16232833/how-to-respond-with-http-400-error-in-a-spring-mvc-responsebody-method-returnin/40518283#40518283
Attachments:
Issue Links:
2 votes, 6 watchers
The text was updated successfully, but these errors were encountered: