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 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 {
|
||||||
|
|||||||
@ -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(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user