fixed response object
This commit is contained in:
parent
93760fd7b7
commit
6d0409c6c8
@ -2,20 +2,10 @@ package ru.dragonestia.picker.api.impl.exception;
|
||||
|
||||
import ru.dragonestia.picker.api.exception.ApiException;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
@ApiException
|
||||
public class GraphqlException extends RuntimeException {
|
||||
|
||||
private final Map<String, String> details;
|
||||
|
||||
public GraphqlException(Map<String, String> details) {
|
||||
super(details.get("message"));
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public Map<String, String> getDetails() {
|
||||
return Collections.unmodifiableMap(details);
|
||||
public GraphqlException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,13 +107,8 @@ public class RestTemplate {
|
||||
}
|
||||
|
||||
if (node.has("errors")) {
|
||||
var details = new HashMap<String, String>();
|
||||
for (Iterator<Map.Entry<String, JsonNode>> it = node.fields(); it.hasNext(); ) {
|
||||
var entry = it.next();
|
||||
|
||||
details.put(entry.getKey(), entry.getValue().textValue());
|
||||
}
|
||||
throw new GraphqlException(details);
|
||||
var details = node.get("errors").get(0);
|
||||
throw new GraphqlException(details.get("message").asText());
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@ -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) {
|
||||
return new Room(room.getId().getValue(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user