Skip to content

Commit

Permalink
Merge pull request #1655 from lf-lang/fix-lfc-npe
Browse files Browse the repository at this point in the history
Fix NPE in lfc error reporting
  • Loading branch information
lhstrh authored Mar 16, 2023
2 parents 4c4b411 + 3e2824a commit a78d86b
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions org.lflang/src/org/lflang/cli/CliBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,26 +207,29 @@ public void validateResource(Resource resource) {
assert resource != null;

List<Issue> issues = this.validator.validate(
resource, CheckMode.ALL, CancelIndicator.NullImpl);
resource, CheckMode.ALL, CancelIndicator.NullImpl);

for (Issue issue : issues) {
// Issues may also relate to imported resources.
URI uri = issue.getUriToProblem();
try {
issueCollector.accept(
new LfIssue(
issue.getMessage(),
issue.getSeverity(),
issue.getLineNumber(),
issue.getColumn(),
issue.getLineNumberEnd(),
issue.getColumnEnd(),
issue.getLength(),
FileUtil.toPath(uri)));
} catch (IOException e) {
reporter.printError(
"Unable to convert '" + uri + "' to path." + e);
URI uri = issue.getUriToProblem();
Path path = null;
if (uri != null) {
try {
path = FileUtil.toPath(uri);
} catch (IOException e) {
reporter.printError("Unable to convert '" + uri + "' to path." + e);
}
}
issueCollector.accept(
new LfIssue(
issue.getMessage(),
issue.getSeverity(),
issue.getLineNumber(),
issue.getColumn(),
issue.getLineNumberEnd(),
issue.getColumnEnd(),
issue.getLength(),
path));
}
}

Expand Down

0 comments on commit a78d86b

Please sign in to comment.