| 9 | import static java.util.Collections.singletonList; |
| 10 | |
| 11 | @Internal |
| 12 | public class InvalidSyntaxError implements GraphQLError { |
| 13 | |
| 14 | private final String message; |
| 15 | private final String sourcePreview; |
| 16 | private final String offendingToken; |
| 17 | private final List<SourceLocation> locations = new ArrayList<>(); |
| 18 | |
| 19 | public InvalidSyntaxError(SourceLocation sourceLocation, String msg) { |
| 20 | this(singletonList(sourceLocation), msg); |
| 21 | } |
| 22 | |
| 23 | public InvalidSyntaxError(List<SourceLocation> sourceLocations, String msg) { |
| 24 | this(sourceLocations, msg, null, null); |
| 25 | } |
| 26 | |
| 27 | public InvalidSyntaxError(List<SourceLocation> sourceLocations, String msg, String sourcePreview, String offendingToken) { |
| 28 | this.message = msg; |
| 29 | this.sourcePreview = sourcePreview; |
| 30 | this.offendingToken = offendingToken; |
| 31 | if (sourceLocations != null) { |
| 32 | this.locations.addAll(sourceLocations); |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | @Override |
| 37 | public String getMessage() { |
| 38 | return message; |
| 39 | } |
| 40 | |
| 41 | @Override |
| 42 | public List<SourceLocation> getLocations() { |
| 43 | return locations; |
| 44 | } |
| 45 | |
| 46 | public String getSourcePreview() { |
| 47 | return sourcePreview; |
| 48 | } |
| 49 | |
| 50 | public String getOffendingToken() { |
| 51 | return offendingToken; |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public ErrorType getErrorType() { |
| 56 | return ErrorType.InvalidSyntax; |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public String toString() { |
| 61 | return "InvalidSyntaxError{" + |
| 62 | " message=" + message + |
| 63 | " ,offendingToken=" + offendingToken + |
| 64 | " ,locations=" + locations + |
| 65 | " ,sourcePreview=" + sourcePreview + |
| 66 | '}'; |
| 67 | } |
| 68 |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…