| 12 | import java.util.List; |
| 13 | |
| 14 | @Internal |
| 15 | class BaseError extends GraphQLException implements GraphQLError { |
| 16 | protected static final SourceLocation NO_WHERE = new SourceLocation(-1, -1); |
| 17 | |
| 18 | private final Node node; |
| 19 | |
| 20 | public BaseError(Node node, String msg) { |
| 21 | super(msg); |
| 22 | this.node = node; |
| 23 | } |
| 24 | |
| 25 | public static String lineCol(Node node) { |
| 26 | SourceLocation sourceLocation = node.getSourceLocation() == null ? NO_WHERE : node.getSourceLocation(); |
| 27 | return String.format("[@%d:%d]", sourceLocation.getLine(), sourceLocation.getColumn()); |
| 28 | } |
| 29 | |
| 30 | @Override |
| 31 | public List<SourceLocation> getLocations() { |
| 32 | return node == null ? Collections.singletonList(NO_WHERE) : Collections.singletonList(node.getSourceLocation()); |
| 33 | } |
| 34 | |
| 35 | @Override |
| 36 | public ErrorType getErrorType() { |
| 37 | return ErrorType.ValidationError; |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public String toString() { |
| 42 | return getMessage(); |
| 43 | } |
| 44 | |
| 45 | |
| 46 | @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") |
| 47 | @Override |
| 48 | public boolean equals(Object o) { |
| 49 | return GraphqlErrorHelper.equals(this, o); |
| 50 | } |
| 51 | |
| 52 | @Override |
| 53 | public int hashCode() { |
| 54 | return GraphqlErrorHelper.hashCode(this); |
| 55 | } |
| 56 | |
| 57 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…