mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-11 11:12:44 +00:00
Merge pull request #3118 from G-Ambatte/separateApiErrors-#2975
Identify API errors and send error response
This commit is contained in:
@@ -472,9 +472,18 @@ const getPureError = (error)=>{
|
|||||||
};
|
};
|
||||||
|
|
||||||
app.use(async (err, req, res, next)=>{
|
app.use(async (err, req, res, next)=>{
|
||||||
const status = err.status || err.code || 500;
|
err.originalUrl = req.originalUrl;
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|
||||||
|
if(err.originalUrl?.startsWith('/api/')) {
|
||||||
|
// console.log('API error');
|
||||||
|
res.status(err.status || err.response?.status || 500).send(err.message || err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log('non-API error');
|
||||||
|
const status = err.status || err.code || 500;
|
||||||
|
|
||||||
req.ogMeta = { ...defaultMetaTags,
|
req.ogMeta = { ...defaultMetaTags,
|
||||||
title : 'Error Page',
|
title : 'Error Page',
|
||||||
description : 'Something went wrong!'
|
description : 'Something went wrong!'
|
||||||
|
|||||||
Reference in New Issue
Block a user