change: 401 logging
This commit is contained in:
parent
03cc0f02b7
commit
c6005af51e
1 changed files with 6 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue