Skip to content

Commit ffa81de

Browse files
committed
Code review: throw exception with cause
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 #347. Co-authored-by: Alexander Kriegisch <Alexander@Kriegisch.name>
1 parent 164348f commit ffa81de

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

plexus-compiler-manager/src/main/java/org/codehaus/plexus/compiler/manager/DefaultCompilerManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public Compiler getCompiler(String compilerId) throws NoSuchCompilerException {
6969
} catch (Exception e) {
7070
// DI could not construct compiler
7171
log.error(ERROR_MESSAGE, compilerId);
72-
throw new NoSuchCompilerException(compilerId);
72+
throw new NoSuchCompilerException(compilerId, e);
7373
}
7474
}
7575
}

plexus-compiler-manager/src/main/java/org/codehaus/plexus/compiler/manager/NoSuchCompilerException.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ public class NoSuchCompilerException extends Exception {
3131
private final String compilerId;
3232

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

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

0 commit comments

Comments
 (0)