diff --git a/src/node/routes/errors.ts b/src/node/routes/errors.ts index 712bba604..743699c84 100644 --- a/src/node/routes/errors.ts +++ b/src/node/routes/errors.ts @@ -62,12 +62,16 @@ export const errorHandler: express.ErrorRequestHandler = async (err, req, res, n } export const wsErrorHandler: express.ErrorRequestHandler = async (err, req, res, next) => { - logger.error(`${err.message} ${err.stack}`) let statusCode = 500 if (errorHasStatusCode(err)) { statusCode = err.statusCode } else if (errorHasCode(err) && notFoundCodes.includes(err.code)) { statusCode = HttpCode.NotFound } + if (statusCode >= 500) { + logger.error(`${err.message} ${err.stack}`) + } else { + logger.debug(`${err.message} ${err.stack}`) + } ;(req as WebsocketRequest).ws.end(`HTTP/1.1 ${statusCode} ${err.message}\r\n\r\n`) }