0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 22:52:40 +00:00

Identify API errors and send error response

This commit is contained in:
G.Ambatte
2023-10-29 11:04:07 +13:00
parent f58a7d65b5
commit c5ebd0352d

View File

@@ -489,6 +489,12 @@ app.use(async (err, req, res, next)=>{
};
req.customUrl= '/error';
if(req.originalUrl.startsWith('/api/')) {
console.log('api error');
res.status(err?.status || err?.response?.status || 500).send(err.message || err);
return;
}
const page = await renderPage(req, res);
if(!page) return;
res.send(page);