Skip to content

Commit

Permalink
enable global error-handler again + some error-logging improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
fcaps committed Nov 12, 2023
1 parent dcde321 commit 6efc713
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
7 changes: 6 additions & 1 deletion express.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,12 @@ setInterval(() => {
app.use(function (req, res) {
res.status(404).render('errors/404');
});
app.use(function (req, res) {
app.use(function (err, req, res, next) {
console.error('[error] Incoming request to"', req.originalUrl, '"failed with error "', err.toString(), '"')
if (res.headersSent) {
return next(err);
}

res.status(500).render('errors/500');
});

14 changes: 7 additions & 7 deletions scripts/extractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function getTournamentNews() {
let newshubData = sortedData.filter(article => article.category[1] !== 284);
return await newshubData;
} catch (e) {
console.log(e);
console.error(currentDate, '- [error] extractor::getTournamentNews failed with =>', e.toString());
return null;
}
}
Expand All @@ -52,7 +52,7 @@ async function flashMessage() {
}));
return await data;
} catch (e) {
console.log(e);
console.error(currentDate, '- [error] extractor::flashMessage failed with =>', e.toString());
return null;
}
}
Expand All @@ -72,7 +72,7 @@ async function news() {
}));
return await data;
} catch (e) {
console.log(e);
console.error(currentDate, '- [error] extractor::news failed with =>', e.toString());
return null;
}
}
Expand Down Expand Up @@ -102,7 +102,7 @@ async function newshub() {
let data = sortedData.filter(onlyActiveArticles);
return await data;
} catch (e) {
console.log(e);
console.error(currentDate, '- [error] extractor::newshub failed with =>', e.toString());
return null;
}
}
Expand All @@ -119,7 +119,7 @@ async function fafTeams() {
}));
return await data;
} catch (e) {
console.log(e);
console.error(currentDate, '- [error] extractor::fafTeams failed with =>', e.toString());
return null;
}

Expand All @@ -135,7 +135,7 @@ async function contentCreators() {
}));
return await data;
} catch (e) {
console.log(e);
console.error(currentDate, '- [error] extractor::contentCreators failed with =>', e.toString());
return null;
}

Expand Down Expand Up @@ -222,7 +222,7 @@ module.exports.run = function run() {
.then(data => {
fs.writeFile(`public/js/app/members/${fileName}.json`, JSON.stringify(data), error => {
if (error) {
console.log(error);
console.error(currentDate, '- [error] extractor::run', fileName, 'failed with =>', error.toString());
} else {
console.log(`${currentDate} - ${fileName} file created.`);
}
Expand Down

0 comments on commit 6efc713

Please sign in to comment.