From f38514a7aa7fa3342d8b16935f4ebd9a74d2e381 Mon Sep 17 00:00:00 2001 From: Lukas Holzer Date: Wed, 19 Jul 2023 13:40:55 +0200 Subject: [PATCH] fix: fixes a bug inside the error reporting (#5880) --- src/utils/telemetry/report-error.mjs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/utils/telemetry/report-error.mjs b/src/utils/telemetry/report-error.mjs index 7902a41ab29..c934ec39f3e 100644 --- a/src/utils/telemetry/report-error.mjs +++ b/src/utils/telemetry/report-error.mjs @@ -25,15 +25,19 @@ export const reportError = async function (error, config = {}) { return } + // convert a NotifiableError to an error class + // eslint-disable-next-line unicorn/no-nested-ternary + const err = error instanceof Error ? error : typeof error === 'string' ? new Error(error) : error + const globalConfig = await getGlobalConfig() const options = JSON.stringify({ type: 'error', data: { - message: error.message, - name: error.name, - stack: error.stack, - cause: error.cause, + message: err.message, + name: err.name, + stack: err.stack, + cause: err.cause, severity: config.severity, user: { id: globalConfig.get('userId'),