mirror of
https://github.com/stolksdorf/homebrewery.git
synced 2025-12-21 19:11:31 +00:00
adding in some api tests
This commit is contained in:
26
server/error.js
Normal file
26
server/error.js
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
const ApiError = require('egads').extend('Server Error', 500, 'Generic Server Error');
|
||||
|
||||
ApiError.noBrew = ApiError.extend('Can not find a brew with that id', 404);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ApiError.expressHandler = (err, req, res, next) => {
|
||||
if(err instanceof ApiError){
|
||||
return res.status(err.status).send({
|
||||
type : err.name,
|
||||
message : err.message
|
||||
});
|
||||
}
|
||||
//If server error, print the whole stack for debugging
|
||||
return res.status(500).send({
|
||||
message : err.message,
|
||||
stack : err.stack
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
module.exports = ApiError;
|
||||
Reference in New Issue
Block a user