Skip to content

Commit

Permalink
Print problems when compilation fails
Browse files Browse the repository at this point in the history
This closes #61, #62
  • Loading branch information
ctubbsii committed Nov 23, 2022
1 parent cb54f89 commit aeb5a55
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/net/revelc/code/impsort/ImpSort.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ public Result parseFile(final Path path, final byte[] buf) throws IOException {
List<String> fileLines = readAllLines(file);
ParseResult<CompilationUnit> parseResult =
new JavaParser(new ParserConfiguration().setLanguageLevel(languageLevel)).parse(file);
CompilationUnit unit = parseResult.getResult()
.orElseThrow(() -> new ImpSortException(path, Reason.UNABLE_TO_PARSE));
CompilationUnit unit = parseResult.getResult().orElseThrow(() -> {
parseResult.getProblems().forEach(System.out::println);
return new ImpSortException(path, Reason.UNABLE_TO_PARSE);
});
if (!parseResult.isSuccessful()) {
parseResult.getProblems().forEach(System.out::println);
throw new ImpSortException(path, Reason.PARTIAL_PARSE);
Expand Down

0 comments on commit aeb5a55

Please sign in to comment.