From 95dc9cf8384aa5fb6b8103d1184373f4a71bcd86 Mon Sep 17 00:00:00 2001 From: tycrek Date: Wed, 25 Aug 2021 22:14:08 -0600 Subject: [PATCH] improved error handling --- ass.js | 8 +++----- utils.js | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ass.js b/ass.js index 15f21fe..46cd159 100755 --- a/ass.js +++ b/ass.js @@ -86,12 +86,10 @@ app.use('/', ROUTERS.upload); ASS_PREMIUM.enabled && app.use(ASS_PREMIUM.endpoint, ASS_PREMIUM.router); // skipcq: JS-0093 // '/:resouceId' always needs to be LAST since it's a catch-all route -app.use('/:resourceId', (req, _, next) => (req.resourceId = req.params.resourceId, next()), ROUTERS.resource); // skipcq: JS-0086, JS-0090 +app.use('/:resourceId', (req, _res, next) => (req.resourceId = req.params.resourceId, next()), ROUTERS.resource); // skipcq: JS-0086, JS-0090 -app.use((err, req, res, next) => { - console.error(err); - res.sendStatus(CODE_INTERNAL_SERVER_ERROR); -}); +// Error handler +app.use((err, _req, res, _next) => log.error(err).err(err).callback(() => res.sendStatus(CODE_INTERNAL_SERVER_ERROR))); // Host the server log diff --git a/utils.js b/utils.js index d459a37..00e5502 100755 --- a/utils.js +++ b/utils.js @@ -88,7 +88,7 @@ const logger = new TLog({ logger .env('ASS_ENV') //.enable.process({ uncaughtException: false }).debug('Plugin enabled', 'Process') - .enable.express().debug('Plugin enabled', 'Express') + .enable.express({ handle500: false }).debug('Plugin enabled', 'Express') .enable.socket().debug('Plugin enabled', 'Socket'); const idModes = {