1
0
mirror of https://github.com/stolksdorf/homebrewery.git synced 2025-12-24 07:41:30 +00:00

Added in full test coverage of current spec

This commit is contained in:
Scott Tolksdorf
2017-01-06 17:45:48 -05:00
parent 987363ed41
commit ca40ec5a2d
14 changed files with 413 additions and 170 deletions

View File

@@ -1,14 +1,12 @@
const ApiError = require('egads').extend('Server Error', 500, 'Generic Server Error');
const Error = require('egads').extend('Server Error', 500, 'Generic Server Error');
ApiError.noBrew = ApiError.extend('Can not find a brew with that id', 404);
Error.noBrew = Error.extend('Can not find a brew with that id', 404, 'No Brew Found');
Error.noAuth = Error.extend('You can not access this route', 401, 'Unauthorized');
ApiError.expressHandler = (err, req, res, next) => {
if(err instanceof ApiError){
Error.expressHandler = (err, req, res, next) => {
if(err instanceof Error){
return res.status(err.status).send({
type : err.name,
message : err.message
@@ -23,4 +21,4 @@ ApiError.expressHandler = (err, req, res, next) => {
module.exports = ApiError;
module.exports = Error;