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.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
@ -81,13 +82,18 @@ public class ConfigExecutorService {
catch (HttpClientErrorException e) {
if (e.getStatusCode() == HttpStatus.BAD_REQUEST) {
Map<String, String> responseMap = new Gson().fromJson(e.getResponseBodyAsString(),
new TypeToken<Map<String, String>>() {
Map<String, Object> responseMap = new Gson().fromJson(e.getResponseBodyAsString(),
new TypeToken<Map<String, Object>>() {
}.getType()
);
String details = responseMap.get("details");
throw new ConfigExecutorException(details);
@SuppressWarnings("unchecked")
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 {
throw new RuntimeException(