Print error messages to stderr, not stdout

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

View File

@@ -63,16 +63,16 @@ class Kiss {
try { try {
return operation(); return operation();
} catch (err:CompileError) { } catch (err:CompileError) {
Sys.println(err); Sys.stderr().writeString(err + "\n");
Sys.exit(1); Sys.exit(1);
return null; return null;
} catch (err:UnmatchedBracketSignal) { } 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); Sys.exit(1);
return null; return null;
} catch (err:Exception) { } catch (err:Exception) {
Prelude.print("Error: " + err.message); Sys.stderr().writeString("Error: " + err.message + "\n");
Prelude.print(err.stack.toString()); Sys.stderr().writeString(err.stack.toString() + "\n");
Sys.exit(1); Sys.exit(1);
return null; return null;
} }

View File

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