aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-07-27 14:38:07 +0200
committerChocobozzz <me@florianbigard.com>2022-07-27 14:38:07 +0200
commiteb7b48ce84e5872d1333edd892f2e6104a18d7f1 (patch)
treefed58d9ef381fb1be4936bc636d0392feaec820c /server/middlewares
parente3d6c6434f570f77c0532f86c82f78bcafb399ec (diff)
downloadPeerTube-eb7b48ce84e5872d1333edd892f2e6104a18d7f1.tar.gz
PeerTube-eb7b48ce84e5872d1333edd892f2e6104a18d7f1.tar.zst
PeerTube-eb7b48ce84e5872d1333edd892f2e6104a18d7f1.zip
Prevent logging an error on lazy static 404
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}