From a42f3e8ed8bf736106f8231860d76e95eee10ae2 Mon Sep 17 00:00:00 2001 From: vladp Date: Fri, 20 Mar 2026 16:28:23 +0700 Subject: [PATCH] dev add violation notion --- .../nocopy/service/search/SearchImageService.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/ru/soune/nocopy/service/search/SearchImageService.java b/src/main/java/ru/soune/nocopy/service/search/SearchImageService.java index 8e5e4b4..e896d8a 100644 --- a/src/main/java/ru/soune/nocopy/service/search/SearchImageService.java +++ b/src/main/java/ru/soune/nocopy/service/search/SearchImageService.java @@ -141,17 +141,18 @@ public class SearchImageService { log.info("SearchAPI response code={}, duration={}ms, 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(); if (body == null) { 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; } }