| 14 | import static java.lang.String.format; |
| 15 | |
| 16 | @PublicApi |
| 17 | @NullMarked |
| 18 | public class SerializationError implements GraphQLError { |
| 19 | |
| 20 | private final String message; |
| 21 | private final List<Object> path; |
| 22 | private final CoercingSerializeException exception; |
| 23 | |
| 24 | public SerializationError(ResultPath path, CoercingSerializeException exception) { |
| 25 | this.path = assertNotNull(path).toList(); |
| 26 | this.exception = assertNotNull(exception); |
| 27 | this.message = mkMessage(path, exception); |
| 28 | } |
| 29 | |
| 30 | private String mkMessage(ResultPath path, CoercingSerializeException exception) { |
| 31 | return format("Can't serialize value (%s) : %s", path, exception.getMessage()); |
| 32 | } |
| 33 | |
| 34 | public CoercingSerializeException getException() { |
| 35 | return exception; |
| 36 | } |
| 37 | |
| 38 | @Override |
| 39 | public String getMessage() { |
| 40 | return message; |
| 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public @Nullable List<SourceLocation> getLocations() { |
| 45 | return exception.getLocations(); |
| 46 | } |
| 47 | |
| 48 | @Override |
| 49 | public ErrorType getErrorType() { |
| 50 | return ErrorType.DataFetchingException; |
| 51 | } |
| 52 | |
| 53 | @Override |
| 54 | public List<Object> getPath() { |
| 55 | return path; |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public @Nullable Map<String, Object> getExtensions() { |
| 60 | return exception.getExtensions(); |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public String toString() { |
| 65 | return "SerializationError{" + |
| 66 | "path=" + path + |
| 67 | ", exception=" + exception + |
| 68 | '}'; |
| 69 | } |
| 70 | |
| 71 | @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") |
| 72 | @Override |
| 73 | public boolean equals(Object o) { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…