From 6fb5744271e03c4316f36b5bc156799339977864 Mon Sep 17 00:00:00 2001 From: Andrew Hayward Date: Fri, 10 May 2013 15:09:16 +0100 Subject: [PATCH] Handling API errors in the API --- api.js | 4 ++++ controllers/program.js | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api.js b/api.js index dc5eb63..cddaf39 100644 --- a/api.js +++ b/api.js @@ -41,6 +41,10 @@ function api (method, default_query) { return res.json(data); req.remote = data; + + if (data.error) + return next(data); + next(); }); } diff --git a/controllers/program.js b/controllers/program.js index 031b631..c5107e8 100644 --- a/controllers/program.js +++ b/controllers/program.js @@ -162,12 +162,8 @@ module.exports = function (app) { }); app.get('/badges', api('getBadges'), function (req, res, next) { - var err = req.remote.error; var data = req.remote; - if (err) - return next({status: err, message: data.message}); - res.render('badges/list.html', { filters: getFilters(), items: data.badges,