We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 394b2d6 commit 5b03656Copy full SHA for 5b03656
lib/LogMessage.js
@@ -229,6 +229,8 @@ class LogMessage {
229
* @returns {Error} The original error stubbed with a toJSON() method.
230
*/
231
static stubError(err) {
232
+ if(typeof err.toJSON === 'function') return err;
233
+
234
err.toJSON = function () {
235
const keys = [
236
'name',
@@ -239,9 +241,9 @@ class LogMessage {
239
241
return keys.reduce((obj, key) => {
240
242
if(key in err) {
243
const val = err[key];
- if(typeof val !== 'function') {
- obj[key] = val;
244
- }
245
+ if(typeof val === 'function') return obj;
246
+ obj[key] = val;
247
}
248
249
return obj;
0 commit comments