Spaces:
Sleeping
Sleeping
Download src/middleware/error.middleware.ts from sardarbipul/test: direct link, hf CLI and curl.
- Browser
- Download file 536 Bytes
-
https://huggingface.co/spaces/sardarbipul/test/resolve/main/src/middleware/error.middleware.ts
- Command line
-
hf download hf://spaces/sardarbipul/test/src/middleware/error.middleware.ts
-
curl -L -o error.middleware.ts https://huggingface.co/spaces/sardarbipul/test/resolve/main/src/middleware/error.middleware.ts
536 Bytes
| import { Request, Response, NextFunction } from 'express'; | |
| import { logger } from '../utils/logger'; | |
| export function errorHandler( | |
| err: any, | |
| req: Request, | |
| res: Response, | |
| next: NextFunction | |
| ): void { | |
| logger.error(`Unhandled HTTP Error [${req.method} ${req.path}]:`, err); | |
| const statusCode = err.status || err.statusCode || 500; | |
| const message = err.message || 'Internal Server Error'; | |
| res.status(statusCode).json({ | |
| error: { | |
| message, | |
| statusCode, | |
| timestamp: new Date().toISOString(), | |
| }, | |
| }); | |
| } | |