@ ExceptionHandler ( ValidationException . class ) public ResponseEntity < ExceptionInfo > handleValidationException ( final HttpServletRequest request , final ValidationException ex ) { logRequest ( request , ex ) ; final ExceptionInfo response = new ExceptionInfo ( ) ; response . setMessage ( ex . getMessage ( ) ) ; response . setExceptionClass ( ex . getClass ( ) . getName ( ) ) ; response . setErrorCode ( SpServerError . SP_REPO_CONSTRAINT_VIOLATION . getKey ( ) ) ; return new ResponseEntity <> ( response , HttpStatus . BAD_REQUEST ) ; }
Method for handling exception of type ValidationException which is thrown in case the request is rejected due to invalid requests . Called by the Spring - Framework for exception handling .