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); }