Spaces:
Sleeping
Sleeping
Download backend/src/middlewares/errorHandler.ts from cuteepeiarchu/PathFinders: direct link, hf CLI and curl.
- Browser
- Download file 509 Bytes
-
https://huggingface.co/spaces/cuteepeiarchu/PathFinders/resolve/main/backend/src/middlewares/errorHandler.ts
- Command line
-
hf download hf://spaces/cuteepeiarchu/PathFinders/backend/src/middlewares/errorHandler.ts
-
curl -L -o errorHandler.ts https://huggingface.co/spaces/cuteepeiarchu/PathFinders/resolve/main/backend/src/middlewares/errorHandler.ts
509 Bytes
| import { NextFunction, Request, Response } from "express"; | |
| import { AppError } from "../utils/appError"; | |
| export const errorHandler = ( | |
| error: Error, | |
| _request: Request, | |
| response: Response, | |
| _next: NextFunction, | |
| ) => { | |
| if (error instanceof AppError) { | |
| return response.status(error.statusCode).json({ | |
| success: false, | |
| message: error.message, | |
| }); | |
| } | |
| return response.status(500).json({ | |
| success: false, | |
| message: "Internal server error.", | |
| detail: error.message, | |
| }); | |
| }; | |