-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement
Milestone
Description
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
Attachments:
- ControllerAdvice.java (853 bytes)
- ResourceException.java (1.31 kB)
Issue Links:
- Provide a standard exception hierarchy for REST end points [SPR-12531] #17136 Provide a standard exception hierarchy for REST end points
- ExceptionHandlerExceptionResolver should not log propagated exceptions at warn level [SPR-14907] #19473 ExceptionHandlerExceptionResolver should not log propagated exceptions at warn level
2 votes, 6 watchers
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement