summaryrefslogtreecommitdiff
path: root/routes
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-07-03 11:12:11 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2012-07-03 11:12:11 +0200
commit9b1195430a2dc636e8325ecbb7445855d9d98259 (patch)
tree4a7a03c5cc939cde1c4017426d3a3a0262399b9d /routes
parent2aba868b67edc249774d1f9b9a5fd4c497383623 (diff)
downloadcollection-json-explorer-9b1195430a2dc636e8325ecbb7445855d9d98259.tar.gz
collection-json-explorer-9b1195430a2dc636e8325ecbb7445855d9d98259.tar.bz2
collection-json-explorer-9b1195430a2dc636e8325ecbb7445855d9d98259.tar.xz
collection-json-explorer-9b1195430a2dc636e8325ecbb7445855d9d98259.zip
o Updating error rendering after adding sidebar.
o Showing raw data when rendering errors too.
Diffstat (limited to 'routes')
-rw-r--r--routes/index.js10
1 files changed, 6 insertions, 4 deletions
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);