Created
November 10, 2023 05:15
-
-
Save sandipchitale/381f0060befb8b8f67ac61042dedafe7 to your computer and use it in GitHub Desktop.
ErrorHandling #spring-web-mvc
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
@ExceptionHandler(Exception.class) | |
public ResponseEntity<String> handleError(HttpServletRequest req, Exception ex) { | |
if (ex.getCause() instanceof SocketTimeoutException) { | |
return ResponseEntity.status(HttpStatus.GATEWAY_TIMEOUT).body(HttpStatus.GATEWAY_TIMEOUT.getReasonPhrase()); | |
} | |
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(HttpStatus.INTERNAL_SERVER_ERROR.getReasonPhrase()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment