From 88891f50ecfa83cfc7993fc1dd5595389ff8852b Mon Sep 17 00:00:00 2001 From: Carl-Erik Kopseng Date: Mon, 24 Sep 2018 09:46:36 +0200 Subject: [PATCH] Always print some diagnostics to stderr on error Even if event.error is defined, the other props includes valuable information --- .../webworker/webworker-support-assessment.js | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/test/webworker/webworker-support-assessment.js b/test/webworker/webworker-support-assessment.js index dd6277bdb..e6a87678f 100644 --- a/test/webworker/webworker-support-assessment.js +++ b/test/webworker/webworker-support-assessment.js @@ -24,17 +24,24 @@ if (typeof Worker !== "undefined") { */ function onError(ev) { var error = ev.error; + var msg = + "An error happened at line " + + [ev.lineno, ev.colno].join(":") + + " in file " + + ev.filename + + ": " + + ev.message; if (!error) { - var msg = - "An error happened at line " + - [ev.lineno, ev.colno].join(":") + - " in file " + - ev.filename + - ": " + - ev.message; error = new Error(msg); } + + // `ev.error` might be defined, but still might include + // very little information, which is why we want to + // include as much information as we possibly can + + console.error(msg); // eslint-disable-line no-console + done(error); }