fixed response object

This commit is contained in:
Andrey Terentev 2024-05-27 08:52:22 +07:00 committed by Andrey Terentev
parent 93760fd7b7
commit 6d0409c6c8
3 changed files with 5 additions and 20 deletions

View File

@ -2,20 +2,10 @@ package ru.dragonestia.picker.api.impl.exception;
import ru.dragonestia.picker.api.exception.ApiException; import ru.dragonestia.picker.api.exception.ApiException;
import java.util.Collections;
import java.util.Map;
@ApiException @ApiException
public class GraphqlException extends RuntimeException { public class GraphqlException extends RuntimeException {
private final Map<String, String> details; public GraphqlException(String message) {
super(message);
public GraphqlException(Map<String, String> details) {
super(details.get("message"));
this.details = details;
}
public Map<String, String> getDetails() {
return Collections.unmodifiableMap(details);
} }
} }

View File

@ -107,13 +107,8 @@ public class RestTemplate {
} }
if (node.has("errors")) { if (node.has("errors")) {
var details = new HashMap<String, String>(); var details = node.get("errors").get(0);
for (Iterator<Map.Entry<String, JsonNode>> it = node.fields(); it.hasNext(); ) { throw new GraphqlException(details.get("message").asText());
var entry = it.next();
details.put(entry.getKey(), entry.getValue().textValue());
}
throw new GraphqlException(details);
} }
try { try {

View File

@ -15,7 +15,7 @@ public final class ResponseObject {
} }
} }
public record Room(String id, String nodeId, int slots, boolean locked, boolean persist, String payload) { public record Room(String id, String instanceId, int slots, boolean locked, boolean persist, String payload) {
public static ResponseObject.Room of(ru.dragonestia.picker.model.room.Room room) { public static ResponseObject.Room of(ru.dragonestia.picker.model.room.Room room) {
return new Room(room.getId().getValue(), return new Room(room.getId().getValue(),