mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-06 10:02:43 +00:00
Additional info in errors
This commit is contained in:
@@ -4,17 +4,20 @@ const loginUrl = 'https://www.naturalcrit.com/login';
|
|||||||
|
|
||||||
const errorIndex = (props)=>{
|
const errorIndex = (props)=>{
|
||||||
return {
|
return {
|
||||||
|
// Default catch all
|
||||||
'00' : dedent`
|
'00' : dedent`
|
||||||
## An unknown error occurred!
|
## An unknown error occurred!
|
||||||
|
|
||||||
We aren't sure what happened, but our server wasn't able to find what you
|
We aren't sure what happened, but our server wasn't able to find what you
|
||||||
were looking for.`,
|
were looking for.`,
|
||||||
|
|
||||||
|
// General Google load error
|
||||||
'01' : dedent`
|
'01' : dedent`
|
||||||
## An error occurred while retrieving this brew from Google Drive!
|
## An error occurred while retrieving this brew from Google Drive!
|
||||||
|
|
||||||
Google reported an error while attempting to retrieve a brew from this link.`,
|
Google reported an error while attempting to retrieve a brew from this link.`,
|
||||||
|
|
||||||
|
// Google Drive - 404 : brew deleted or access denied
|
||||||
'02' : dedent`
|
'02' : dedent`
|
||||||
## We can't find this brew in your Google Drive!
|
## We can't find this brew in your Google Drive!
|
||||||
|
|
||||||
@@ -48,6 +51,7 @@ const errorIndex = (props)=>{
|
|||||||
change the storage location of a brew by clicking the Google drive icon by the
|
change the storage location of a brew by clicking the Google drive icon by the
|
||||||
brew title and choosing *transfer my brew to/from Google Drive*.`,
|
brew title and choosing *transfer my brew to/from Google Drive*.`,
|
||||||
|
|
||||||
|
// User is not Authors list
|
||||||
'03' : dedent`
|
'03' : dedent`
|
||||||
## The current logged in user does not have editor access to this brew.
|
## The current logged in user does not have editor access to this brew.
|
||||||
|
|
||||||
@@ -62,30 +66,46 @@ const errorIndex = (props)=>{
|
|||||||
${props.brew.authors?.map((author)=>{return `- ${author}`;}).join('\n') || 'Unable to list authors'}
|
${props.brew.authors?.map((author)=>{return `- ${author}`;}).join('\n') || 'Unable to list authors'}
|
||||||
`,
|
`,
|
||||||
|
|
||||||
|
// User is not logged in
|
||||||
'04' : dedent`
|
'04' : dedent`
|
||||||
## Not logged in
|
## Not logged in
|
||||||
|
|
||||||
User is not logged in. Please log in [here](${loginUrl}).`,
|
User is not logged in. Please log in [here](${loginUrl}).`,
|
||||||
|
|
||||||
|
// Brew load error
|
||||||
'05' : dedent`
|
'05' : dedent`
|
||||||
## No Homebrewery document could be found.
|
## No Homebrewery document could be found.
|
||||||
|
|
||||||
The server could not locate the Homebrewery document.`,
|
The server could not locate the Homebrewery document.
|
||||||
|
|
||||||
|
**Requested access:** ${props.brew.accessType}
|
||||||
|
|
||||||
|
**Brew ID:** ${props.brew.brewId}
|
||||||
|
`,
|
||||||
|
|
||||||
|
// Brew save error
|
||||||
'06' : dedent`
|
'06' : dedent`
|
||||||
## Unable to save Homebrewery document.
|
## Unable to save Homebrewery document.
|
||||||
|
|
||||||
An error occurred wil attempting to save the Homebrewery document.`,
|
An error occurred wil attempting to save the Homebrewery document.`,
|
||||||
|
|
||||||
|
// Brew delete error
|
||||||
'07' : dedent`
|
'07' : dedent`
|
||||||
## Unable to delete Homebrewery document.
|
## Unable to delete Homebrewery document.
|
||||||
|
|
||||||
An error occurred while attempting to remove the Homebrewery document.`,
|
An error occurred while attempting to remove the Homebrewery document.
|
||||||
|
|
||||||
|
**Brew ID:** ${props.brew.brewId}
|
||||||
|
`,
|
||||||
|
|
||||||
|
// Author delete error
|
||||||
'08' : dedent`
|
'08' : dedent`
|
||||||
## Unable to remove user from Homebrewery document.
|
## Unable to remove user from Homebrewery document.
|
||||||
|
|
||||||
An error occurred while attempting to remove the current user from the Homebrewery document author list!`,
|
An error occurred while attempting to remove the user from the Homebrewery document author list!
|
||||||
|
|
||||||
|
**Brew ID:** ${props.brew.brewId}
|
||||||
|
`,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ const api = {
|
|||||||
|
|
||||||
// If after all of that we still don't have a brew, throw an exception
|
// If after all of that we still don't have a brew, throw an exception
|
||||||
if(!stub && !stubOnly) {
|
if(!stub && !stubOnly) {
|
||||||
throw { name: 'BrewLoad Error', message: 'Brew not found', status: 404, HBErrorCode: '05' };
|
throw { name: 'BrewLoad Error', message: 'Brew not found', status: 404, HBErrorCode: '05', accessType: accessType, brewId: id };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean up brew: fill in missing fields with defaults / fix old invalid values
|
// Clean up brew: fill in missing fields with defaults / fix old invalid values
|
||||||
@@ -313,7 +313,7 @@ const api = {
|
|||||||
await HomebrewModel.deleteOne({ _id: brew._id })
|
await HomebrewModel.deleteOne({ _id: brew._id })
|
||||||
.catch((err)=>{
|
.catch((err)=>{
|
||||||
console.error(err);
|
console.error(err);
|
||||||
throw { name: 'BrewDelete Error', message: 'Error while removing', status: 500, HBErrorCode: '07' };
|
throw { name: 'BrewDelete Error', message: 'Error while removing', status: 500, HBErrorCode: '07', brewId: brew._id };
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if(shouldDeleteGoogleBrew) {
|
if(shouldDeleteGoogleBrew) {
|
||||||
@@ -325,7 +325,7 @@ const api = {
|
|||||||
brew.markModified('authors'); //Mongo will not properly update arrays without markModified()
|
brew.markModified('authors'); //Mongo will not properly update arrays without markModified()
|
||||||
await brew.save()
|
await brew.save()
|
||||||
.catch((err)=>{
|
.catch((err)=>{
|
||||||
throw { name: 'BrewAuthorDelete Error', message: err, status: 500, HBErrorCode: '08' };
|
throw { name: 'BrewAuthorDelete Error', message: err, status: 500, HBErrorCode: '08', brewId: brew._id };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user