From 512bb9b4f2bf4a95b7ba60f6a6567c9418cebbf7 Mon Sep 17 00:00:00 2001 From: Stephen Judkins Date: Fri, 10 Dec 2010 15:35:08 -0800 Subject: [PATCH] Fixed issue #6. One can now throw a non-Error object without messing up the entire suite. --- lib/console-runner.js | 11 ++++++++++- test/test-errors.js | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/console-runner.js b/lib/console-runner.js index 50f4352..b3c4223 100644 --- a/lib/console-runner.js +++ b/lib/console-runner.js @@ -119,8 +119,17 @@ exports.run = function(list, options, callback) { if (r.error.message) { sys.puts(' '+r.error.message); + } else { + sys.puts(' '+r.error.toString()); } - var s = r.error.stack.split("\n"); + + var s; + if (r.error.stack && r.error.stack.split) { + s = r.error.stack.split("\n"); + } else { + s = []; + } + if (options.verbosity == 1) { if (s.length > 1) { sys.puts(s[1].replace(process.cwd(), '.')); diff --git a/test/test-errors.js b/test/test-errors.js index 0cbe04d..503cb3a 100644 --- a/test/test-errors.js +++ b/test/test-errors.js @@ -9,6 +9,10 @@ exports['test async error'] = function(test) { }, 500); }; +exports['test a thrown non-Error object'] = function(test) { + throw "a string, not an error"; +} + if (module == require.main) { require('../lib/async_testing').run(__filename, process.ARGV); }