|
12 | 12 | import com.fasterxml.jackson.databind.cfg.CoercionInputShape;
|
13 | 13 | import io.securecodebox.persistence.defectdojo.config.Config;
|
14 | 14 | import io.securecodebox.persistence.defectdojo.exception.LoopException;
|
| 15 | +import io.securecodebox.persistence.defectdojo.exception.PersistenceException; |
15 | 16 | import io.securecodebox.persistence.defectdojo.http.Foo;
|
16 | 17 | import io.securecodebox.persistence.defectdojo.http.ProxyConfigFactory;
|
17 | 18 | import io.securecodebox.persistence.defectdojo.model.Engagement;
|
|
29 | 30 | import org.springframework.http.converter.StringHttpMessageConverter;
|
30 | 31 | import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
31 | 32 | import org.springframework.util.LinkedMultiValueMap;
|
| 33 | +import org.springframework.web.client.RestClientException; |
32 | 34 | import org.springframework.web.client.RestTemplate;
|
33 | 35 | import org.springframework.web.util.UriComponentsBuilder;
|
34 | 36 |
|
@@ -73,14 +75,19 @@ public final T get(long id) {
|
73 | 75 |
|
74 | 76 | final var url = this.config.getUrl() + API_PREFIX + this.getUrlPath() + "/" + id;
|
75 | 77 | log.debug("Requesting URL: {}", url);
|
76 |
| - ResponseEntity<T> response = restTemplate.exchange( |
77 |
| - url, |
78 |
| - HttpMethod.GET, |
79 |
| - payload, |
80 |
| - getModelClass() |
81 |
| - ); |
82 |
| - |
83 |
| - return response.getBody(); |
| 78 | + try { |
| 79 | + ResponseEntity<T> response = restTemplate.exchange( |
| 80 | + url, |
| 81 | + HttpMethod.GET, |
| 82 | + payload, |
| 83 | + getModelClass() |
| 84 | + ); |
| 85 | + |
| 86 | + return response.getBody(); |
| 87 | + } catch (RestClientException e) { |
| 88 | + log.error("Exception while getting data: {}", e.getMessage()); |
| 89 | + throw new PersistenceException("Failed to get data.", e); |
| 90 | + } |
84 | 91 | }
|
85 | 92 |
|
86 | 93 | @Override
|
|
0 commit comments