Skip to content

Commit

Permalink
(#37) - Add dedicated package for sending errors to the client
Browse files Browse the repository at this point in the history
  • Loading branch information
marcos8896 committed Oct 14, 2018
1 parent ebf7e5e commit bdb59b5
Show file tree
Hide file tree
Showing 3 changed files with 1,718 additions and 1,663 deletions.
8 changes: 3 additions & 5 deletions common/hooks/diet.hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* @module DietHooks
*/

const createError = require( 'http-errors' );

const app = require( '../../server/server' );

/**
Expand All @@ -27,11 +29,7 @@ const validateOwnerEditDiet = async ( ctx ) => {
null, { accessToken: id }
);

if ( isOwner !== true ) {

throw new Error( 'Not authorized' );

}
if ( isOwner !== true ) throw createError( 401, 'Not authorized to edit this record' );

return;

Expand Down
Loading

0 comments on commit bdb59b5

Please # to comment.