Permalink
Browse files

Returning more info when JSON parse fails

  • Loading branch information...
1 parent 12e45e9 commit b5f7bac280048311b747fb5fd961cd6d8dc59364 @benrhughes committed Feb 19, 2012
Showing with 3 additions and 7 deletions.
  1. +3 −7 lib/posterous.js
View
@@ -57,14 +57,10 @@ Posterous.prototype.request = function(method, api, args, callback) {
//Work-around, not all API responses are valid json >_>
//Example: Deleting a site gives a response of 'undefined:1'
try {
- var r = JSON.parse(response);
-
- if (r.error) {
- return callback(r.message || r.error);
- }
-
+ var r = JSON.parse(response);
} catch (err) {
- return callback(err, null);
+ var message = 'Error parsing JSON: ' + err + ' in\n' + response;
+ return callback(message, null);
}
callback(null, r);

0 comments on commit b5f7bac

Please sign in to comment.