Created
May 30, 2016 22:09
-
-
Save MafaldaLandeiro/0a72da52ecb4deffeeb35f29e197c9d8 to your computer and use it in GitHub Desktop.
Controller Advice
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
| package org.SpringRestfulServiceExceptionHandler.controller; | |
| import org.springframework.http.HttpStatus; | |
| import org.springframework.http.ResponseEntity; | |
| import org.springframework.web.bind.annotation.ControllerAdvice; | |
| import org.springframework.web.bind.annotation.ExceptionHandler; | |
| @ControllerAdvice(basePackages = { "org.SpringRestfulServiceExceptionHandler.controller" }) | |
| public class RestfulResponseExceptionHandler { | |
| @ExceptionHandler(value = NumberFormatException.class) | |
| public ResponseEntity<Object> numberFormatExceptionExceptionHandler(Exception ex) { | |
| String response = "ERROR MESSAGE"; | |
| return new ResponseEntity<Object>(response, HttpStatus.BAD_REQUEST); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment