Created
June 10, 2020 23:00
-
-
Save dinukadev/73245d97dad2c407af5223502d96105d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ControllerAdvice(annotations = RestController.class) | |
public class ExceptionHandlerAdvice { | |
@ExceptionHandler(InvalidDataException.class) | |
@ResponseStatus(HttpStatus.BAD_REQUEST) | |
public ResponseEntity<String> handleInvalidDataExceptions(InvalidDataException e) { | |
HttpHeaders headers = new HttpHeaders(); | |
headers.setContentType(MediaType.TEXT_PLAIN); | |
return new ResponseEntity<>(e.getMessage(), headers, HttpStatus.BAD_REQUEST); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment