+ private ResponseEntity<String> handleException(Exception throwable) {
+ if (throwable instanceof HttpClientErrorException) {
+ HttpClientErrorException e = (HttpClientErrorException) throwable;
+ return new ResponseEntity<>(e.getMessage(), e.getStatusCode());
+ } else if (throwable instanceof HttpServerErrorException) {
+ HttpServerErrorException e = (HttpServerErrorException) throwable;
+ return new ResponseEntity<>(e.getResponseBodyAsString(), e.getStatusCode());
+ }
+ return new ResponseEntity<>(throwable.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+