add error check for request
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
@@ -48,11 +48,14 @@ public class TimezoneServiceImpl implements TimezoneService {
|
|||||||
@Override
|
@Override
|
||||||
@Cacheable(value = "TZInfoByIp", key = "{#ip}")
|
@Cacheable(value = "TZInfoByIp", key = "{#ip}")
|
||||||
public WorldTimeApiIpResponse getTimeZoneInfoByIp(String ip) {
|
public WorldTimeApiIpResponse getTimeZoneInfoByIp(String ip) {
|
||||||
return restClient
|
return restClient
|
||||||
.get()
|
.get()
|
||||||
.uri("https://worldtimeapi.org/api/ip/" + ip)
|
.uri("https://worldtimeapi.org/api/ip/" + ip)
|
||||||
.retrieve()
|
.retrieve()
|
||||||
.body(WorldTimeApiIpResponse.class);
|
.onStatus(HttpStatusCode::is4xxClientError, (request, response) -> {
|
||||||
|
throw new NotFoundException();
|
||||||
|
})
|
||||||
|
.body(WorldTimeApiIpResponse.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user