From 51d55dedac10d51fe51ce09a50aef3f97eac8358 Mon Sep 17 00:00:00 2001 From: Elin Angelow Date: Tue, 23 Apr 2024 09:29:53 +0300 Subject: [PATCH] fix: handle undef, error... --- lib/helpers.js | 2 +- lib/logger.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/helpers.js b/lib/helpers.js index 2b274d7..de7d4d5 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -4,7 +4,7 @@ function mergeDeep(...objects) { const isObject = obj => obj && typeof obj === 'object'; return objects.reduce((prev, obj) => { - Object.keys(obj).forEach(key => { + obj && Object.keys(obj).forEach(key => { const pVal = prev[key]; const oVal = obj[key]; diff --git a/lib/logger.js b/lib/logger.js index ad9cc9d..2232b1d 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -59,7 +59,12 @@ const Logger = ({ try { return await super.send(data); } catch (e) { - this.log('error', 'Send', e?.stack, data); + this.log( + 'error', + 'Send', + e?.error?.stack || e?.stack || e, + data + ); throw e; } }