Add basic error handling

This commit is contained in:
Andrew Stewart 2014-08-01 13:04:39 -07:00
parent 40a1c0570f
commit 50f3ece923
1 changed files with 5 additions and 0 deletions

View File

@ -54,6 +54,11 @@ var API = module.exports = function API(opts) {
// load route definitions
this.express.use('/api', require('./api/routes'));
// error handling
this.express.use(function(err, req, res, next) {
res.json(500, { error: err.message || "An error occured."})
});
};
API.prototype.defaults = {