From 3a11deff41d361c33e84901238569d06e1b45286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A5le=20Tomten?= Date: Thu, 8 Feb 2024 11:12:49 +0100 Subject: [PATCH] Check that the toString method is available on the error. --- lib/cli/run.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cli/run.js b/lib/cli/run.js index 6eb5ed9a49..92908be435 100644 --- a/lib/cli/run.js +++ b/lib/cli/run.js @@ -369,7 +369,7 @@ exports.handler = async function (argv) { try { await runMocha(mocha, argv); } catch (err) { - if (!err) { + if (!err || !err.toString) { console.error('\n Undefined error:', err); } else { console.error('\n' + (err.stack || `Error: ${err.message || err}`));