Skip to content

Commit

Permalink
Fixed NPE in ScriptError if INode is empty (openhab#1985)
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
  • Loading branch information
cweitkamp authored Dec 22, 2020
1 parent bf14e10 commit 7ce96ac
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,16 @@ public ScriptError(final String message, final int line, final int column, final
public ScriptError(final String message, final EObject atEObject) {
this.message = message;
INode node = NodeModelUtils.getNode(atEObject);
LineAndColumn lac = NodeModelUtils.getLineAndColumn(node, node.getOffset());
this.line = lac.getLine();
this.column = lac.getColumn();
this.length = node.getEndOffset() - node.getOffset();
if (node == null) {
this.line = 0;
this.column = 0;
this.length = -1;
} else {
LineAndColumn lac = NodeModelUtils.getLineAndColumn(node, node.getOffset());
this.line = lac.getLine();
this.column = lac.getColumn();
this.length = node.getEndOffset() - node.getOffset();
}
}

/**
Expand Down

0 comments on commit 7ce96ac

Please sign in to comment.