This repository was archived by the owner on Feb 27, 2023. It is now read-only.
forked from graphql-java/graphql-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSerializationError.java
More file actions
72 lines (55 loc) · 1.74 KB
/
SerializationError.java
File metadata and controls
72 lines (55 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package graphql;
import graphql.execution.ExecutionPath;
import graphql.language.SourceLocation;
import graphql.schema.CoercingSerializeException;
import java.util.List;
import static graphql.Assert.assertNotNull;
import static java.lang.String.format;
@PublicApi
public class SerializationError implements GraphQLError {
private final String message;
private final List<Object> path;
private final CoercingSerializeException exception;
public SerializationError(ExecutionPath path, CoercingSerializeException exception) {
this.path = assertNotNull(path).toList();
this.exception = assertNotNull(exception);
this.message = mkMessage(path, exception);
}
private String mkMessage(ExecutionPath path, CoercingSerializeException exception) {
return format("Can't serialize value (%s) : %s", path, exception.getMessage());
}
public CoercingSerializeException getException() {
return exception;
}
@Override
public String getMessage() {
return message;
}
@Override
public List<SourceLocation> getLocations() {
return null;
}
@Override
public ErrorType getErrorType() {
return ErrorType.DataFetchingException;
}
public List<Object> getPath() {
return path;
}
@Override
public String toString() {
return "SerializationError{" +
"path=" + path +
"exception=" + exception +
'}';
}
@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
@Override
public boolean equals(Object o) {
return GraphqlErrorHelper.equals(this, o);
}
@Override
public int hashCode() {
return GraphqlErrorHelper.hashCode(this);
}
}