Prevent sending log error to server on 404

pull/5486/head
Chocobozzz 2022-12-28 15:15:44 +01:00
parent ded68a9760
commit d522369bed
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 13 additions and 1 deletions

View File

@ -87,7 +87,11 @@ export class RestExtractor {
if (err.status !== undefined) {
const errorMessage = this.buildServerErrorMessage(err)
logger.error(`Backend returned code ${err.status}, errorMessage is: ${errorMessage}`)
const message = `Backend returned code ${err.status}, errorMessage is: ${errorMessage}`
if (err.status === HttpStatusCode.NOT_FOUND_404) logger.clientError(message)
else logger.error(message)
return errorMessage
}

View File

@ -27,6 +27,10 @@ class Logger {
warn (message: LoggerMessage, meta?: LoggerMeta) {
this.runHooks('warn', message, meta)
this.clientWarn(message, meta)
}
clientWarn (message: LoggerMessage, meta?: LoggerMeta) {
if (meta) console.warn(message, meta)
else console.warn(message)
}
@ -34,6 +38,10 @@ class Logger {
error (message: LoggerMessage, meta?: LoggerMeta) {
this.runHooks('error', message, meta)
this.clientError(message, meta)
}
clientError (message: LoggerMessage, meta?: LoggerMeta) {
if (meta) console.error(message, meta)
else console.error(message)
}