Add more info to client error stacktrace

pull/5215/head
Chocobozzz 2022-08-17 09:53:47 +02:00
parent 7804e577de
commit 426a8cab45
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 8 additions and 3 deletions

View File

@ -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()