From bfc4c43d4ae8718ec21b300dc7ce77ef0c0e007b Mon Sep 17 00:00:00 2001 From: Roberto Schiavone Date: Wed, 6 Jun 2018 22:45:00 +0200 Subject: [PATCH 1/2] Check if Error object has stack property. Fixes #34. --- signale.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/signale.js b/signale.js index 8f17373a..19eac1c3 100644 --- a/signale.js +++ b/signale.js @@ -192,7 +192,7 @@ class Signale { } } - if (msg instanceof Error) { + if (msg instanceof Error && typeof msg.stack !== 'undefined') { const [name, ...rest] = msg.stack.split('\n'); if (this._config.underlineMessage) { signale.push(chalk.underline(name)); From 684d84ef5afc61941965955430306a880573aff6 Mon Sep 17 00:00:00 2001 From: Roberto Schiavone Date: Thu, 7 Jun 2018 20:00:00 +0200 Subject: [PATCH 2/2] Integrate review suggestions As per @klauscfhq request, the check now relies upon type conversion to prevent any falsy value from making it through. --- signale.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/signale.js b/signale.js index 19eac1c3..8eab11bb 100644 --- a/signale.js +++ b/signale.js @@ -192,7 +192,7 @@ class Signale { } } - if (msg instanceof Error && typeof msg.stack !== 'undefined') { + if (msg instanceof Error && msg.stack) { const [name, ...rest] = msg.stack.split('\n'); if (this._config.underlineMessage) { signale.push(chalk.underline(name));