Untitled
jeclipse
plain_text
a year ago
647 B
5
Indexable
@ExceptionHandler(APIException.class) public ResponseEntity<ErrorDTO> handleException(APIException exception) { HttpStatus httpStatus = HttpStatus.resolve(exception.getStatusCode()); // Default to INTERNAL_SERVER_ERROR if the status code is not recognized if (httpStatus == null) { httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; } log.error(exception.getResponseBody()); return ResponseEntity.status(httpStatus) .body( ErrorDTO.builder() .code(httpStatus.getReasonPhrase()) .message(exception.getResponseBody()) .build()); }
Editor is loading...
Leave a Comment