Skip to content

Commit befebb1

Browse files
author
David Reed
committed
Printing cause of compilation failure - System.exit() is not ideal but it avoids printing the Truncate Class File error that run.sh has after a compilation failure and run.sh fails to dynamically reload after that anyway
1 parent 7d8d79a commit befebb1

3 files changed

Lines changed: 25 additions & 5 deletions

File tree

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
package com.sandwich.util.io;
22

3-
import java.io.File;
4-
import java.util.Arrays;
5-
63
import com.sandwich.koan.ui.SuitePresenter;
74
import com.sandwich.koan.util.ApplicationUtils;
85

6+
import java.io.File;
7+
import java.util.Arrays;
8+
import java.util.Scanner;
9+
910
public class CompilationFailureLogger implements CompilationListener {
10-
public void compilationFailed(File src, String[] command, Process p, Throwable x) {
11+
public void compilationFailed(File src, String[] command, Process p, Throwable x) {
1112
SuitePresenter presenter = ApplicationUtils.getPresenter();
1213
presenter.displayError("\n*****************************************************************");
14+
presenter.displayError("COMPILE FAILED! Exit status was: " + p.exitValue());
15+
presenter.displayError("\nCompile Output:");
16+
presenter.displayError(StreamUtils.convertStreamToString(p.getErrorStream()));
17+
presenter.displayError("Compile Command:");
1318
presenter.displayError(Arrays.toString(command));
14-
presenter.displayError(src.getAbsolutePath() + " does not compile. exit status was: " + p.exitValue());
1519
presenter.displayError("*****************************************************************\n");
20+
System.exit(1);
1621
}
1722
public void compilationSucceeded(File src, String[] command, Process p, Throwable x) { }
1823
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.sandwich.util.io;
2+
3+
import java.io.InputStream;
4+
5+
public class StreamUtils {
6+
7+
public static String convertStreamToString(InputStream stream) {
8+
try {
9+
return new java.util.Scanner(stream).useDelimiter("\\A").next();
10+
} catch (java.util.NoSuchElementException e) {
11+
return "";
12+
}
13+
}
14+
15+
}

koans/lib/koans.jar

100755100644
4.53 KB
Binary file not shown.

0 commit comments

Comments
 (0)