From c6005af51e76591c869589f475fafcc511f9c49d Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Thu, 9 Jan 2025 12:34:05 +0100 Subject: [PATCH] change: 401 logging --- src/middleware/errorHandler.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/middleware/errorHandler.ts b/src/middleware/errorHandler.ts index e3ce2ec..8f25d29 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; @@ -10,8 +11,11 @@ export default function errorHandler(err: ExceptionBase | Error, req: Request, r status = err.statusCode; msg = err.message; } - - console.log("Handler", err); + if (err instanceof UnauthorizedRequestException) { + console.log("Unauthorized Requests Detected", err.message); + } else { + console.log("Handler", err); + } res.status(status).send(msg); }