handle throw of non-Errors gracefully (#3492)

This commit is contained in:
Alex Lam S.L
2019-10-17 06:29:02 +08:00
committed by GitHub
parent 7b5350b459
commit b571619d31

View File

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