mirror of
https://github.com/Mueller-Patrick/Betterzon.git
synced 2026-04-27 07:40:10 +00:00
BETTERZON-38: Added error handler, preparation for DB accessing
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import HttpException from "../common/http-exception";
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
|
||||
export const errorHandler = (
|
||||
error: HttpException,
|
||||
request: Request,
|
||||
response: Response,
|
||||
next: NextFunction
|
||||
) => {
|
||||
const status = error.statusCode || 500;
|
||||
const message =
|
||||
error.message || "It's not you. It's us. We are having some problems.";
|
||||
|
||||
response.status(status).send(message);
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Request, Response, NextFunction } from "express";
|
||||
|
||||
export const notFoundHandler = (
|
||||
request: Request,
|
||||
response: Response,
|
||||
next: NextFunction
|
||||
) => {
|
||||
|
||||
const message = "Resource not found";
|
||||
|
||||
response.status(404).send(message);
|
||||
};
|
||||
Reference in New Issue
Block a user