@@ -141,17 +141,18 @@ public class SearchImageService {
|
|||||||
log.info("SearchAPI response code={}, duration={}ms, engine={}",
|
log.info("SearchAPI response code={}, duration={}ms, engine={}",
|
||||||
response.code(), duration, engine);
|
response.code(), duration, engine);
|
||||||
|
|
||||||
if (!response.isSuccessful()) {
|
|
||||||
String errorBody = response.body() != null ? response.body().string() : "null";
|
|
||||||
throw new IOException("API error " + response.code() + ": " + errorBody);
|
|
||||||
}
|
|
||||||
|
|
||||||
ResponseBody body = response.body();
|
ResponseBody body = response.body();
|
||||||
if (body == null) {
|
if (body == null) {
|
||||||
throw new IOException("Empty response body");
|
throw new IOException("Empty response body");
|
||||||
}
|
}
|
||||||
|
|
||||||
return body.string();
|
String responseBody = body.string();
|
||||||
|
|
||||||
|
if (!response.isSuccessful()) {
|
||||||
|
throw new IOException("API error " + response.code() + ": " + responseBody);
|
||||||
|
}
|
||||||
|
|
||||||
|
return responseBody;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user