Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

Catch empty throws

Linus Unnebäckefc53eb86e7d
diff --git a/lib/runner.js b/lib/runner.js
index a56e5302..61fc27aa 100644
--- a/lib/runner.js
+++ b/lib/runner.js
@@ -532,7 +532,13 @@ Runner.prototype.runSuite = function(suite, fn){
*/
Runner.prototype.uncaught = function(err){
- debug('uncaught exception %s', err.message);
+ if (err) {
+ debug('uncaught exception %s', err.message);
+ } else {
+ debug('uncaught undefined exception');
+ err = new Error('Catched undefined error, did you throw without specifying what?');
+ }
+
var runnable = this.currentRunnable;
if (!runnable || 'failed' == runnable.state) return;
runnable.clearTimeout();