forked from matyb/java-koans
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Printing cause of compilation failure - System.exit() is not ideal bu…
…t 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
- Loading branch information
David Reed
committed
Aug 17, 2012
1 parent
7d8d79a
commit befebb1
Showing
3 changed files
with
25 additions
and
5 deletions.
There are no files selected for viewing
15 changes: 10 additions & 5 deletions
15
koans-lib/src/com/sandwich/util/io/CompilationFailureLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
package com.sandwich.util.io; | ||
|
||
import java.io.File; | ||
import java.util.Arrays; | ||
|
||
import com.sandwich.koan.ui.SuitePresenter; | ||
import com.sandwich.koan.util.ApplicationUtils; | ||
|
||
import java.io.File; | ||
import java.util.Arrays; | ||
import java.util.Scanner; | ||
|
||
public class CompilationFailureLogger implements CompilationListener { | ||
public void compilationFailed(File src, String[] command, Process p, Throwable x) { | ||
public void compilationFailed(File src, String[] command, Process p, Throwable x) { | ||
SuitePresenter presenter = ApplicationUtils.getPresenter(); | ||
presenter.displayError("\n*****************************************************************"); | ||
presenter.displayError("COMPILE FAILED! Exit status was: " + p.exitValue()); | ||
presenter.displayError("\nCompile Output:"); | ||
presenter.displayError(StreamUtils.convertStreamToString(p.getErrorStream())); | ||
presenter.displayError("Compile Command:"); | ||
presenter.displayError(Arrays.toString(command)); | ||
presenter.displayError(src.getAbsolutePath() + " does not compile. exit status was: " + p.exitValue()); | ||
presenter.displayError("*****************************************************************\n"); | ||
System.exit(1); | ||
} | ||
public void compilationSucceeded(File src, String[] command, Process p, Throwable x) { } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.sandwich.util.io; | ||
|
||
import java.io.InputStream; | ||
|
||
public class StreamUtils { | ||
|
||
public static String convertStreamToString(InputStream stream) { | ||
try { | ||
return new java.util.Scanner(stream).useDelimiter("\\A").next(); | ||
} catch (java.util.NoSuchElementException e) { | ||
return ""; | ||
} | ||
} | ||
|
||
} |
Binary file not shown.