add error check for request

Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
2024-10-28 16:00:26 +01:00
parent a96664369b
commit 19b00f8c61

View File

@@ -48,11 +48,14 @@ public class TimezoneServiceImpl implements TimezoneService {
@Override
@Cacheable(value = "TZInfoByIp", key = "{#ip}")
public WorldTimeApiIpResponse getTimeZoneInfoByIp(String ip) {
return restClient
.get()
.uri("https://worldtimeapi.org/api/ip/" + ip)
.retrieve()
.body(WorldTimeApiIpResponse.class);
return restClient
.get()
.uri("https://worldtimeapi.org/api/ip/" + ip)
.retrieve()
.onStatus(HttpStatusCode::is4xxClientError, (request, response) -> {
throw new NotFoundException();
})
.body(WorldTimeApiIpResponse.class);
}
@Override