Skip to content

Commit 3a88791

Browse files
committed
Fixed NPE for error locations from JSON schemas
1 parent 8be7087 commit 3a88791

File tree

1 file changed

+5
-3
lines changed
  • src/main/com/intellij/lang/jsgraphql/types/schema/idl/errors

1 file changed

+5
-3
lines changed

src/main/com/intellij/lang/jsgraphql/types/schema/idl/errors/BaseError.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The MIT License (MIT)
3232
@SuppressWarnings("rawtypes")
3333
@Internal
3434
public class BaseError extends GraphQLException implements GraphQLError {
35-
protected static final SourceLocation NO_WHERE = new SourceLocation(-1, -1);
35+
protected static final SourceLocation EMPTY = new SourceLocation(-1, -1);
3636

3737
private final Node node;
3838
private final List<Node> myReferences = new ArrayList<>();
@@ -43,13 +43,15 @@ public BaseError(@Nullable Node node, @Nullable String msg) {
4343
}
4444

4545
public static String lineCol(Node node) {
46-
SourceLocation sourceLocation = node.getSourceLocation() == null ? NO_WHERE : node.getSourceLocation();
46+
SourceLocation sourceLocation = node.getSourceLocation() == null ? EMPTY : node.getSourceLocation();
4747
return String.format("[@%d:%d]", sourceLocation.getLine(), sourceLocation.getColumn());
4848
}
4949

5050
@Override
5151
public List<SourceLocation> getLocations() {
52-
return node == null ? Collections.singletonList(NO_WHERE) : Collections.singletonList(node.getSourceLocation());
52+
return node == null || node.getSourceLocation() == null ?
53+
Collections.singletonList(EMPTY) :
54+
Collections.singletonList(node.getSourceLocation());
5355
}
5456

5557
@Override

0 commit comments

Comments
 (0)