Permalink
Browse files

better handling of server errors

  • Loading branch information...
mikepb committed May 19, 2012
1 parent 15bccac commit 6c46a45c8ab81c352ac2a4bb831d611a4dccc624
Showing with 9 additions and 6 deletions.
  1. +4 −2 index.js
  2. +4 −3 sage.js
  3. +1 −1 sage.min.js
View
@@ -73,8 +73,10 @@ Base._request = function(method, uri, query, body, headers, auth, callback) {
}, function(err, res, data) {
if (callback) {
if (method === 'HEAD') data = res.headers;
- if (!err && data) data = self._response(data);
- if (data && data.error) err = new Error(data.error);
+ else if (!err && data) {
+ if (data.error) err = new Error(data.error);
+ else data = self._response(data);
+ }
if (res) status = res.statusCode, headers = res.headers;
callback(err, data, status, headers, res);
}
View
@@ -272,11 +272,12 @@ Apache License
} catch (e) {
err = e;
}
+ if (!err) {
+ if (data.error) err = new Error(data.error);
+ else if (data) data = self._response(data);
+ }
}
- if (!err && data) data = self._response(data);
- if (data && data.error) err = new Error(data.error);
-
callback(err, data, xhr.status, headers, xhr);
}
};
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 6c46a45

Please sign in to comment.