0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-05 21:02:43 +00:00

Remove duplicate error logs for google drive update / new

Errors are now logged once in the central error handler in app.js
This commit is contained in:
Trevor Buckner
2024-09-26 19:00:07 -04:00
parent 84736980c9
commit ff9a75f6b6
3 changed files with 7 additions and 17 deletions

View File

@@ -498,7 +498,7 @@ app.use(async (err, req, res, next)=>{
err.originalUrl = req.originalUrl; err.originalUrl = req.originalUrl;
console.error(err); console.error(err);
if(err.originalUrl?.startsWith('/api/')) { if(err.originalUrl?.startsWith('/api')) {
// console.log('API error'); // console.log('API error');
res.status(err.status || err.response?.status || 500).send(err); res.status(err.status || err.response?.status || 500).send(err);
return; return;

View File

@@ -172,7 +172,6 @@ const GoogleActions = {
}) })
.catch((err)=>{ .catch((err)=>{
console.log('Error saving to google'); console.log('Error saving to google');
console.error(err);
throw (err); throw (err);
}); });

View File

@@ -242,11 +242,8 @@ const api = {
let googleId, saved; let googleId, saved;
if(saveToGoogle) { if(saveToGoogle) {
googleId = await api.newGoogleBrew(req.account, newHomebrew, res) googleId = await api.newGoogleBrew(req.account, newHomebrew, res);
.catch((err)=>{
console.error(err);
res.status(err?.status || err?.response?.status || 500).send(err?.message || err);
});
if(!googleId) return; if(!googleId) return;
api.excludeStubProps(newHomebrew); api.excludeStubProps(newHomebrew);
newHomebrew.googleId = googleId; newHomebrew.googleId = googleId;
@@ -351,19 +348,13 @@ const api = {
brew.googleId = undefined; brew.googleId = undefined;
} else if(!brew.googleId && saveToGoogle) { } else if(!brew.googleId && saveToGoogle) {
// If we don't have a google id and the user wants to save to google, create the google brew and set the google id on the brew // If we don't have a google id and the user wants to save to google, create the google brew and set the google id on the brew
brew.googleId = await api.newGoogleBrew(req.account, api.excludeGoogleProps(brew), res) brew.googleId = await api.newGoogleBrew(req.account, api.excludeGoogleProps(brew), res);
.catch((err)=>{
console.error(err);
res.status(err.status || err.response.status).send(err.message || err);
});
if(!brew.googleId) return; if(!brew.googleId) return;
} else if(brew.googleId) { } else if(brew.googleId) {
// If the google id exists and no other actions are being performed, update the google brew // If the google id exists and no other actions are being performed, update the google brew
const updated = await GoogleActions.updateGoogleBrew(api.excludeGoogleProps(brew)) const updated = await GoogleActions.updateGoogleBrew(api.excludeGoogleProps(brew));
.catch((err)=>{
console.error(err);
res.status(err?.response?.status || 500).send(err);
});
if(!updated) return; if(!updated) return;
} }