Skip to content

Commit

Permalink
CeylonRunJsTool: never exit: always throw
Browse files Browse the repository at this point in the history
Launcher will catch and call exit for us if required, just throw the exit code
  • Loading branch information
FroMage committed Oct 8, 2015
1 parent dae20e6 commit cf65cb7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
Expand Up @@ -10,4 +10,8 @@ public class CeylonRunJsException extends ToolError {
public CeylonRunJsException(String message) {
super(message);
}

public CeylonRunJsException(String message, int exitCode) {
super(message, exitCode);
}
}
23 changes: 5 additions & 18 deletions src/main/java/com/redhat/ceylon/compiler/js/CeylonRunJsTool.java
Expand Up @@ -179,28 +179,16 @@ private static boolean isExe(String p) {
private List<String> args;
private PrintStream output;
private boolean debug;
private boolean throwOnError;

public CeylonRunJsTool() {
super(CeylonRunJsMessages.RESOURCE_BUNDLE);
}

/**
* Tell the tool not to exit on a non-zero exit code from node, but throw otherwise. This is not
* used by the command-line, but can be useful when invoked via the API.
* @param throwOnError true to throw instead of calling System.exit. Defaults to false.
* Ignored: this is now always true.
* @deprecated this is now always true.
*/
public void setThrowOnError(boolean throwOnError) {
this.throwOnError = throwOnError;
}

/**
* Check if we throw on a non-zero exit code from node, rather than exit. This is not
* used by the command-line, but can be useful when invoked via the API.
* @return true to throw instead of calling System.exit. Defaults to false.
*/
public boolean isThrowOnError() {
return throwOnError;
}

/** Sets the PrintStream to use for output. Default is System.out. */
Expand Down Expand Up @@ -478,10 +466,9 @@ public void run() throws Exception {
}
int exitCode = nodeProcess.waitFor();
if (exitCode != 0) {
if(throwOnError)
throw new RuntimeException("Node process exited with non-zero exit code: "+exitCode);
else
System.exit(exitCode==11?2:exitCode);
if(exitCode == 11)
exitCode = 2;
throw new CeylonRunJsException("Node process exited with non-zero exit code: "+exitCode, exitCode);
}
}

Expand Down

1 comment on commit cf65cb7

@FroMage
Copy link
Member Author

@FroMage FroMage commented on cf65cb7 Oct 8, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.