1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-12-28 16:31:36 +00:00

Improved compiler errors - removing exception trace and using proper exit code.

This commit is contained in:
jespergravgaard 2019-03-12 18:14:45 +01:00
parent 6adb0c6d2d
commit fa6ed8bff6
2 changed files with 11 additions and 3 deletions

View File

@ -134,8 +134,6 @@ public class Compiler {
pass5GenerateAndOptimizeAsm();
return program;
} catch(Exception e) {
System.out.println("EXCEPTION DURING COMPILE " + e.getMessage());
System.out.println(getLog().toString());
throw e;
}
}

View File

@ -93,6 +93,9 @@ public class KickC implements Callable<Void> {
@CommandLine.Option(names = {"-fragment" }, description = "Print the ASM code for a named fragment. The fragment is loaded/synthesized and the ASM variations are written to the output.")
private String fragment = null;
/** Program Exit Code signaling a compile error. */
public static final int COMPILE_ERROR = 1;
public static void main(String[] args) {
CommandLine.call(new KickC(), args);
}
@ -156,7 +159,14 @@ public class KickC implements Callable<Void> {
}
System.out.println("Compiling " + kcFile);
Program program = compiler.compile(kcFile.toString());
Program program = null;
try {
program = compiler.compile(kcFile.toString());
} catch(CompileError e) {
// Print the error and exit with compile error
System.err.print(e.getMessage());
System.exit(COMPILE_ERROR);
}
Path asmPath = outputDir.resolve(asmFileName);
System.out.println("Writing asm file " + asmPath);