-
- private HttpEntity<Object> createJsonHttpEntity(Object content) {
- HttpHeaders headers = new HttpHeaders();
- headers.setContentType(MediaType.APPLICATION_JSON);
- return new HttpEntity<>(content, headers);
- }
-
- 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);
- }
-