From 426a8cab459dd924df50d4e27f15feba4819b859 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 17 Aug 2022 09:53:47 +0200 Subject: Add more info to client error stacktrace --- client/src/root-helpers/logger.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'client/src/root-helpers') diff --git a/client/src/root-helpers/logger.ts b/client/src/root-helpers/logger.ts index cd559cfa7..0dcda525e 100644 --- a/client/src/root-helpers/logger.ts +++ b/client/src/root-helpers/logger.ts @@ -95,9 +95,9 @@ class Logger { } private buildStackServerLogPayload (message: LoggerMessage, meta?: LoggerMeta) { - if (message instanceof Error) return message.stack - if (meta instanceof Error) return meta.stack - if (meta?.err instanceof Error) return meta.err.stack + if (message instanceof Error) return this.buildStack(message) + if (meta instanceof Error) return this.buildStack(meta) + if (meta?.err instanceof Error) return this.buildStack(meta.err) return undefined } @@ -128,6 +128,11 @@ class Logger { hookObj.hook(message, meta) } } + + private buildStack (err: Error) { + return `${err.message}\n${err.stack || ''}` + + } } const logger = window.logger || new Logger() -- cgit v1.2.3