This commit is contained in:
kochetkov 2024-12-09 16:18:01 +03:00
parent 0a34aff6a6
commit c113a26e59

View file

@ -8,6 +8,7 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken; import com.google.gson.reflect.TypeToken;
@ -81,13 +82,18 @@ public class ConfigExecutorService {
catch (HttpClientErrorException e) { catch (HttpClientErrorException e) {
if (e.getStatusCode() == HttpStatus.BAD_REQUEST) { if (e.getStatusCode() == HttpStatus.BAD_REQUEST) {
Map<String, String> responseMap = new Gson().fromJson(e.getResponseBodyAsString(), Map<String, Object> responseMap = new Gson().fromJson(e.getResponseBodyAsString(),
new TypeToken<Map<String, String>>() { new TypeToken<Map<String, Object>>() {
}.getType() }.getType()
); );
String details = responseMap.get("details"); @SuppressWarnings("unchecked")
throw new ConfigExecutorException(details); Map<String, String> details = (Map<String, String>) responseMap.get("details");
String detailsStr = details.entrySet()
.stream()
.map(entry -> entry.getKey() + " : " + entry.getValue())
.collect(Collectors.joining("\n"));
throw new ConfigExecutorException(detailsStr);
} }
else { else {
throw new RuntimeException( throw new RuntimeException(