handle throw of non-Errors gracefully

This commit is contained in:
alexlamsl 2019-10-17 05:04:17 +08:00
parent 7b5350b459
commit 8bf62b61d7

View File

@ -959,14 +959,19 @@ if (require.main !== module) {
return;
}
function writeln(stream, msg) {
if (typeof msg != "undefined") {
stream.write(typeof msg == "string" ? msg : msg.stack || "" + msg);
}
stream.write("\n");
}
function println(msg) {
if (typeof msg != "undefined") process.stdout.write(typeof msg == "string" ? msg : msg.stack);
process.stdout.write("\n");
writeln(process.stdout, msg);
}
function errorln(msg) {
if (typeof msg != "undefined") process.stderr.write(typeof msg == "string" ? msg : msg.stack);
process.stderr.write("\n");
writeln(process.stderr, msg);
}
function try_beautify(code, toplevel, result, printfn) {