From 55d4a952c3b1cbfd2c91538b1e1f9efdb6485870 Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Thu, 9 Jan 2025 12:38:07 +0100 Subject: [PATCH] change: minimize logging on custom errors --- src/middleware/errorHandler.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/middleware/errorHandler.ts b/src/middleware/errorHandler.ts index e3ce2ec..92e45ad 100644 --- a/src/middleware/errorHandler.ts +++ b/src/middleware/errorHandler.ts @@ -1,6 +1,7 @@ import { Request, Response } from "express"; import { ExceptionBase } from "../exceptions/exceptionsBaseType"; import CustomRequestException from "../exceptions/customRequestException"; +import UnauthorizedRequestException from "../exceptions/unauthorizedRequestException"; export default function errorHandler(err: ExceptionBase | Error, req: Request, res: Response, next: Function) { let status = 500; @@ -11,7 +12,11 @@ export default function errorHandler(err: ExceptionBase | Error, req: Request, r msg = err.message; } - console.log("Handler", err); + if (err instanceof CustomRequestException) { + console.log("Custom Handler", status, msg); + } else { + console.log("Error Handler", err); + } res.status(status).send(msg); }