1
0
Fork 0

Add more info to client error stacktrace

This commit is contained in:
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

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