filemonczyk filemonczyk - 1 year ago 86
Java Question

Accessing the error object inside of exceptionhandler method

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

this is my code:

public ResponseEntity handleException(){
return ResponseEntity
.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).

Answer Source

Pass in the exception

public ResponseEntity handleException(DataInputException exception) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download