Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @RestControllerAdvice
- public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
- @Override
- protected ResponseEntity<Object> handleExceptionInternal(java.lang.Exception e, Object body, HttpHeaders headers, HttpStatus status, WebRequest request) {
- return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(logOrSomeShit(e));
- }
- @Override
- protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex, HttpHeaders headers, HttpStatus status, WebRequest request) {
- // Return HTTP 422: UNPROCESSABLE_ENTITY in case that a client tries to use an endpoint with incorrect arguments
- return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).build();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement