import { NextFunction, Request, Response } from "express" import { ApiErrorHandler } from "../error/api-error.handler.ts" export function ErrorHandlingMiddleware(err: Error, req: Request, res: Response, next: NextFunction) { if (err instanceof ApiErrorHandler) { return res.status(err.status).json({message: err.message}) } return res.status(500).json({message: "Непредвиденная ошибка"}) }