mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-20 07:32:43 +00:00
Add support for custom HBErrorCodes
This commit is contained in:
@@ -23,7 +23,7 @@ const ErrorPage = createClass({
|
||||
},
|
||||
|
||||
render : function(){
|
||||
const errorText = ErrorIndex()[this.props.brew.status.toString()] || '';
|
||||
const errorText = ErrorIndex()[this.props.brew.HBErrorCode.toString()] || '';
|
||||
|
||||
return <UIPage brew={{ title: 'Crit Fail!' }}>
|
||||
<div className='dataGroup'>
|
||||
|
||||
@@ -2,7 +2,18 @@ const dedent = require('dedent-tabs').default;
|
||||
|
||||
const errorIndex = ()=>{
|
||||
return {
|
||||
"404" : dedent`
|
||||
'00' : dedent`
|
||||
## An unknown error occurred!
|
||||
|
||||
We aren't sure what happened, but our server wasn't able to find what you
|
||||
were looking for.`,
|
||||
|
||||
'01' : dedent`
|
||||
## An error occurred while retrieving this brew from Google Drive!
|
||||
|
||||
Google reported an error while attempting to retrieve a brew from this link.`,
|
||||
|
||||
'02' : dedent`
|
||||
## We can't find this brew in your Google Drive!
|
||||
|
||||
This error tells us your file was saved on your Google Drive, but the link
|
||||
|
||||
@@ -475,7 +475,9 @@ app.use(async (err, req, res, next)=>{
|
||||
req.brew = {
|
||||
title : 'Error - Something went wrong!',
|
||||
text : err.errors?.map((error)=>{return error.message;}).join('\n\n') || err.message || 'Unknown error!',
|
||||
status : status
|
||||
status : status,
|
||||
HBErrorCode : err.HBErrorCode ?? '00',
|
||||
pureError : getPureError(err)
|
||||
};
|
||||
req.customUrl= '/error';
|
||||
|
||||
|
||||
@@ -58,8 +58,8 @@ const api = {
|
||||
});
|
||||
// Throw any error caught while attempting to retrieve Google brew.
|
||||
if(googleError) {
|
||||
// console.log(googleError);
|
||||
throw { ...new Error, ...googleError };
|
||||
const reason = googleError.errors[0].reason;
|
||||
throw { ...Error, ...googleError, HBErrorCode: reason == 'notFound' ? '02' : '01' };
|
||||
}
|
||||
// Combine the Homebrewery stub with the google brew, or if the stub doesn't exist just use the google brew
|
||||
stub = stub ? _.assign({ ...api.excludeStubProps(stub), stubbed: true }, api.excludeGoogleProps(googleBrew)) : googleBrew;
|
||||
|
||||
Reference in New Issue
Block a user