patches v1.0.1 #38
1 changed files with 6 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
import { Request, Response } from "express";
|
import { Request, Response } from "express";
|
||||||
import { ExceptionBase } from "../exceptions/exceptionsBaseType";
|
import { ExceptionBase } from "../exceptions/exceptionsBaseType";
|
||||||
import CustomRequestException from "../exceptions/customRequestException";
|
import CustomRequestException from "../exceptions/customRequestException";
|
||||||
|
import UnauthorizedRequestException from "../exceptions/unauthorizedRequestException";
|
||||||
|
|
||||||
export default function errorHandler(err: ExceptionBase | Error, req: Request, res: Response, next: Function) {
|
export default function errorHandler(err: ExceptionBase | Error, req: Request, res: Response, next: Function) {
|
||||||
let status = 500;
|
let status = 500;
|
||||||
|
@ -11,7 +12,11 @@ export default function errorHandler(err: ExceptionBase | Error, req: Request, r
|
||||||
msg = err.message;
|
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);
|
res.status(status).send(msg);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue