Print error messages to stderr, not stdout

This commit is contained in:
2021-01-17 19:03:45 -07:00
parent 5a669fc9ea
commit aa2ff67d59
2 changed files with 6 additions and 6 deletions

View File

@@ -63,16 +63,16 @@ class Kiss {
try {
return operation();
} catch (err:CompileError) {
Sys.println(err);
Sys.stderr().writeString(err + "\n");
Sys.exit(1);
return null;
} catch (err:UnmatchedBracketSignal) {
Sys.println(Stream.toPrint(err.position) + ': Unmatched ${err.type}');
Sys.stderr().writeString(Stream.toPrint(err.position) + ': Unmatched ${err.type}\n');
Sys.exit(1);
return null;
} catch (err:Exception) {
Prelude.print("Error: " + err.message);
Prelude.print(err.stack.toString());
Sys.stderr().writeString("Error: " + err.message + "\n");
Sys.stderr().writeString(err.stack.toString() + "\n");
Sys.exit(1);
return null;
}

View File

@@ -99,8 +99,8 @@ class Reader {
public static function nextToken(stream:Stream, expect:String) {
var tok = stream.expect(expect, () -> stream.takeUntilOneOf(terminators));
if (tok.length == 0) {
Sys.println('Kiss reader error!');
Sys.println(stream.position().toPrint() + ': Expected $expect');
Sys.stderr().writeString('Kiss reader error!\n');
Sys.stderr().writeString(stream.position().toPrint() + ': Expected $expect\n');
Sys.exit(1);
}
return tok;