Skip to content

Commit

Permalink
Code review: throw exception with cause
Browse files Browse the repository at this point in the history
In order to be able to do that at all, I had to add a constructor taking
a throwable first. Now, even though a cause is propagated, at the time
of writing this Maven Compiler will just catch the
NoSuchCompilerException we throw, ignore its message and root cause and
throw a new MojoExecutionException instead. :-/

Relates to codehaus-plexus#347.
  • Loading branch information
kriegaex committed Feb 4, 2024
1 parent a3c52c6 commit ad1164b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public Compiler getCompiler(String compilerId) throws NoSuchCompilerException {
} catch (Exception e) {
// DI could not construct compiler
log.error(ERROR_MESSAGE, compilerId);
throw new NoSuchCompilerException(compilerId);
throw new NoSuchCompilerException(compilerId, e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ public class NoSuchCompilerException extends Exception {
private final String compilerId;

public NoSuchCompilerException(String compilerId) {
super("No such compiler '" + compilerId + "'.");
this(compilerId, null);
}

public NoSuchCompilerException(String compilerId, Throwable cause) {
super("No such compiler '" + compilerId + "'", cause);
this.compilerId = compilerId;
}

Expand Down

0 comments on commit ad1164b

Please sign in to comment.