- return handleException(e);
- }
- }
-
- 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());
- } else if (throwable instanceof SSLException) {
- SSLException e = (SSLException) throwable;
- return new ResponseEntity<>("Could not create WebClient " + e.getMessage(),
- HttpStatus.INTERNAL_SERVER_ERROR);