0

Is there any way to get inside to the exception object when using annotation @ExceptionHandler?

this is my code:

@ExceptionHandler(DataInputException.class)
    public ResponseEntity handleException(){
         return ResponseEntity
                    .status(HttpStatus.BAD_REQUEST)
                    .body("Entity contains null or forbidden values");
    }

I'd like to have returned message to contain customized info about perticular fields. (That's why I need error object).

1 Answer 1

3

Pass in the exception

@ExceptionHandler(DataInputException.class)
public ResponseEntity handleException(DataInputException exception) {
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.