Skip to content

Commit

Permalink
GH-86: Fix exception causes being omitted from Maven output
Browse files Browse the repository at this point in the history
  • Loading branch information
ascopes committed Feb 4, 2024
1 parent fbff0d0 commit 730fa6e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ public void execute() throws MojoExecutionException, MojoFailureException {
throw new MojoExecutionException("Protoc invocation failed");
}
} catch (ResolutionException | IOException ex) {
throw new MojoFailureException(this, ex.getMessage(), ex.getMessage());
var mojoFailureException = new MojoFailureException(this, ex.getMessage(), ex.getMessage());
mojoFailureException.initCause(ex);
throw mojoFailureException;

Check warning on line 269 in src/main/java/io/github/ascopes/protobufmavenplugin/AbstractGenerateMojo.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/io/github/ascopes/protobufmavenplugin/AbstractGenerateMojo.java#L267-L269

Added lines #L267 - L269 were not covered by tests
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ public Collection<ProtoFileListing> createProtoFileListings(
}

if (!exceptions.isEmpty()) {
var causeIterator = exceptions.iterator();

Check warning on line 98 in src/main/java/io/github/ascopes/protobufmavenplugin/source/ProtoSourceResolver.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/io/github/ascopes/protobufmavenplugin/source/ProtoSourceResolver.java#L98

Added line #L98 was not covered by tests
var ex = new IOException("Failed to create listings asynchronously");
exceptions.forEach(ex::addSuppressed);
ex.initCause(causeIterator.next());
causeIterator.forEachRemaining(ex::addSuppressed);

Check warning on line 101 in src/main/java/io/github/ascopes/protobufmavenplugin/source/ProtoSourceResolver.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/io/github/ascopes/protobufmavenplugin/source/ProtoSourceResolver.java#L100-L101

Added lines #L100 - L101 were not covered by tests
throw ex;
}

Expand Down

0 comments on commit 730fa6e

Please sign in to comment.