Skip to content

Commit

Permalink
Return non-zero if error (thanks jondrean)
Browse files Browse the repository at this point in the history
  • Loading branch information
Franco Montenegro committed Aug 14, 2016
1 parent bce8a9b commit 22ede11
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/main/java/com/ruke/vrjassc/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
import java.util.Collection;

public class Main {

static final int COMPILE_ERROR_STATUS_CODE = 1;
static final int JMPQ_ERROR_STATUS_CODE = 2;
static final int IO_ERROR_STATUS_CODE = 3;
static final int OTHER_ERROR_STATUS_CODE = 4;

protected static void displayHelp() {
System.out.println("-help Display this help!");
Expand All @@ -39,7 +44,6 @@ public static void main(String[] args) {
ArrayList<String> toCompile = new ArrayList<String>();
String resultPath = null;
String logPath = null;
boolean error = false;
boolean onlySuggestions = false;
String[] suggestionOptions = null;

Expand Down Expand Up @@ -101,7 +105,6 @@ public static void main(String[] args) {
editor.close();
}
} catch (Exception e) {
error = true;
if (logWriter != null) {
logWriter.write(e.getMessage());
}
Expand Down Expand Up @@ -149,7 +152,6 @@ public static void main(String[] args) {
}
}
} catch (CompileException ce) {
error = true;
System.out.println(ce.getMessage());

if (logWriter != null) {
Expand All @@ -168,18 +170,19 @@ public static void main(String[] args) {
logWriter.write(System.lineSeparator() + toCompile.get(i).replace("\t", " "));
}
}

System.exit(COMPILE_ERROR_STATUS_CODE);
} catch (JmpqError jmpqe) {
error = true;
if (logWriter != null) {
logWriter.write(jmpqe.getMessage());
}
System.exit(JMPQ_ERROR_STATUS_CODE);
} catch (IOException e) {
error = true;
if (logWriter != null) {
logWriter.write("Could not load blizzard.j or common.j");
}
System.exit(IO_ERROR_STATUS_CODE);
} catch (Exception e) {
error = true;
if (logWriter != null) {
String msg = e.getMessage();

Expand All @@ -189,6 +192,7 @@ public static void main(String[] args) {
e.printStackTrace(logWriter);
}
}
System.exit(OTHER_ERROR_STATUS_CODE);
}

if (logWriter != null) {
Expand Down

0 comments on commit 22ede11

Please sign in to comment.