diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2019-10-17 06:29:02 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-17 06:29:02 +0800 |
commit | b571619d3129727da2fddd2fadff1ea98625a9a9 (patch) | |
tree | 76bf621c20c3df13443f2a9d03f23fa02f9d3196 /test | |
parent | 7b5350b4599bf26ff5bea12ed02757ca9ac7eecd (diff) | |
download | tracifyjs-b571619d3129727da2fddd2fadff1ea98625a9a9.tar.gz tracifyjs-b571619d3129727da2fddd2fadff1ea98625a9a9.zip |
handle `throw` of non-`Error`s gracefully (#3492)
Diffstat (limited to 'test')
-rw-r--r-- | test/ufuzz.js | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/test/ufuzz.js b/test/ufuzz.js index a77d161c..86125477 100644 --- a/test/ufuzz.js +++ b/test/ufuzz.js @@ -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) { |