PIbd-23_Dyakonov_R_R_SUBD_P.../server/middleware/error-handling.middleware.js
2024-03-24 19:49:46 +04:00

9 lines
323 B
JavaScript

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