Skip to content

Commit

Permalink
Pass all error properties to message generator
Browse files Browse the repository at this point in the history
  • Loading branch information
G-Ambatte committed Jun 25, 2023
1 parent da8e7ec commit e5ef0ae
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion client/homebrew/pages/errorPage/errorPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const ErrorPage = createClass({
},

render : function(){
const errorText = ErrorIndex()[this.props.brew.HBErrorCode.toString()] || '';
const errorText = ErrorIndex(this.props)[this.props.brew.HBErrorCode.toString()] || '';

return <UIPage brew={{ title: 'Crit Fail!' }}>
<div className='dataGroup'>
Expand Down
11 changes: 9 additions & 2 deletions client/homebrew/pages/errorPage/errors/errorIndex.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const dedent = require('dedent-tabs').default;

const errorIndex = ()=>{
const errorIndex = (props)=>{
return {
'00' : dedent`
## An unknown error occurred!
Expand Down Expand Up @@ -49,7 +49,14 @@ const errorIndex = ()=>{
'03' : dedent`
## The current logged in user does not have editor access to this brew.
If you believe you should have access to this brew, ask the file owner to invite you as an author by opening the brew, viewing the Properties tab, and adding your username to the "invited authors" list. You can then try to access this document again.`,
If you believe you should have access to this brew, ask the file owner to invite you
as an author by opening the brew, viewing the Properties tab, and adding your username
to the "invited authors" list. You can then try to access this document again.
Current Authors:
${props.brew.authors?.map((author)=>{return `- ${author}`;}).join('\n') || 'Unable to list authors'}
`,

'04' : dedent`
## No Homebrewery document could be found.
Expand Down
1 change: 1 addition & 0 deletions server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ app.use(async (err, req, res, next)=>{
description : 'Something went wrong!'
};
req.brew = {
...err,
title : 'Error - Something went wrong!',
text : err.errors?.map((error)=>{return error.message;}).join('\n\n') || err.message || 'Unknown error!',
status : status,
Expand Down
2 changes: 1 addition & 1 deletion server/homebrew.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const api = {
const isAuthor = stub?.authors?.includes(req.account?.username);
const isInvited = stub?.invitedAuthors?.includes(req.account?.username);
if(accessType === 'edit' && (authorsExist && !(isAuthor || isInvited))) {
throw { name: 'Access Error', message: 'User is not an Author', status: 401, HBErrorCode: '03' };
throw { name: 'Access Error', message: 'User is not an Author', status: 401, HBErrorCode: '03', authors: stub.authors };
}

// If after all of that we still don't have a brew, throw an exception
Expand Down

0 comments on commit e5ef0ae

Please sign in to comment.