Skip to content

Commit ddbd223

Browse files
committed
[GR-16925] Show stacktrace for errors in BuildInformationProcessor.
PullRequest: truffleruby/929
2 parents 70722f6 + ca24126 commit ddbd223

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/processor/java/org/truffleruby/processor/BuildInformationProcessor.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public synchronized void init(ProcessingEnvironment env) {
5959
revision = runCommand("git rev-parse --short=8 HEAD");
6060
compileDate = runCommand("git log -1 --date=short --pretty=format:%cd");
6161
} catch (Throwable e) {
62-
env.getMessager().printMessage(Kind.ERROR, e.getClass() + " " + e.getMessage());
62+
throw new Error(e);
6363
}
6464
}
6565

@@ -80,13 +80,20 @@ private File findHome() throws URISyntaxException {
8080
return source.getParentFile();
8181
}
8282

83-
private String runCommand(String command) throws IOException {
83+
private String runCommand(String command) throws IOException, InterruptedException {
8484
final Process git = new ProcessBuilder(command.split("\\s+"))
8585
.directory(trufflerubyHome)
8686
.start();
87+
final String firstLine;
8788
try (BufferedReader reader = new BufferedReader(new InputStreamReader(git.getInputStream()))) {
88-
return reader.readLine();
89+
firstLine = reader.readLine();
8990
}
91+
92+
final int exitCode = git.waitFor();
93+
if (exitCode != 0) {
94+
throw new Error("Command " + command + " failed with exit code " + exitCode);
95+
}
96+
return firstLine;
9097
}
9198

9299
@Override

0 commit comments

Comments
 (0)