Created
April 24, 2020 17:14
-
-
Save Raouf25/ee452d39a95269a663f2877667ae8df4 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 | |
@CrossOrigin | |
public class ExceptionHandlerController { | |
@ExceptionHandler({ClientUnavailableException.class}) | |
public ResponseEntity<ErrorAndCodeResponse> badRequest(BackendException e) { | |
ErrorAndCodeResponse error = new ErrorAndCodeResponse(e.getCode().name(), e.getCode().getMessage(), e.getAdditionalInfo()); | |
return new ResponseEntity<>(error, HttpStatus.BAD_REQUEST); | |
} | |
@ExceptionHandler(ResourceNotFoundException.class) | |
public ResponseEntity<ErrorAndCodeResponse> notFound(BackendException e) { | |
ErrorAndCodeResponse error = new ErrorAndCodeResponse(e.getCode().name(), e.getCode().getMessage(), e.getAdditionalInfo()); | |
return new ResponseEntity<>(error, HttpStatus.NOT_FOUND); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment