Permalink
Browse files

parse JSON error response in client

  • Loading branch information...
1 parent 7213aea commit bb3744cf83fae33c59cc65209bde5050c5fc657f @zaach zaach committed Jan 23, 2013
Showing with 7 additions and 0 deletions.
  1. +7 −0 client/client.js
View
@@ -50,6 +50,13 @@ function request(args, cb) {
},
processData: false,
error: function(data, res, status) {
+ if (typeof data === 'string') {
+ try {
+ data = JSON.parse(data);
+ } catch (e) {
+ return cb && cb('Invalid JSON response: ' + e);
+ }
+ }
if (cb) cb({ error: data, status: status });
},
complete: function () {

0 comments on commit bb3744c

Please sign in to comment.