From 9b1195430a2dc636e8325ecbb7445855d9d98259 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 3 Jul 2012 11:12:11 +0200 Subject: o Updating error rendering after adding sidebar. o Showing raw data when rendering errors too. --- routes/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'routes') diff --git a/routes/index.js b/routes/index.js index ce0d6aa..fca41dd 100644 --- a/routes/index.js +++ b/routes/index.js @@ -18,10 +18,11 @@ exports.index = function(req, res){ }; exports.render = function(req, res) { - function sendErr(err) { + function sendErr(err, rawBody) { res.render('data', { url: req.query.url, - err: err + err: err, + rawBody: rawBody }); } var u = url.parse(req.query.url, true); @@ -35,17 +36,18 @@ exports.render = function(req, res) { u.query = _.extend({}, u.query, params); fetchCollection(url.format(u), function(err, headers, body) { if(err) { - sendErr(err); + sendErr(err, body); } else { var parsedBody; try { parsedBody = JSON.parse(body); } catch(e) { - sendErr('Unable to parse JSON: ' + e); + sendErr('Unable to parse JSON: ' + e, body); return; } var collection = collection_json.fromObject(parsedBody).collection; + console.log(collection); var isUrl = function(u) { try { var x = url.parse(u); -- cgit v1.2.3