aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
Diffstat (limited to 'server/middlewares')
-rw-r--r--server/middlewares/error.ts17
1 files changed, 16 insertions, 1 deletions
diff --git a/server/middlewares/error.ts b/server/middlewares/error.ts
index 34c87a26d..96a85012a 100644
--- a/server/middlewares/error.ts
+++ b/server/middlewares/error.ts
@@ -40,6 +40,21 @@ function apiFailMiddleware (req: express.Request, res: express.Response, next: e
40 if (next) next() 40 if (next) next()
41} 41}
42 42
43function handleStaticError (err: any, req: express.Request, res: express.Response, next: express.NextFunction) {
44 const message = err.message || ''
45
46 if (message.includes('ENOENT')) {
47 return res.fail({
48 status: err.status || HttpStatusCode.INTERNAL_SERVER_ERROR_500,
49 message: err.message,
50 type: err.name
51 })
52 }
53
54 return next(err)
55}
56
43export { 57export {
44 apiFailMiddleware 58 apiFailMiddleware,
59 handleStaticError
45} 60}