change: minimize logging on custom errors

This commit is contained in:
Julian Krauser 2025-01-09 12:38:07 +01:00
parent 03cc0f02b7
commit 55d4a952c3

View file

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