Permalink
Browse files

Merge pull request #4 from mpj/patch-1

Better error handling in requestCallback
  • Loading branch information...
2 parents 1b21d8e + 9c4104d commit 5fb9f804b2fdc6e19119221600c44eec05afb7f6 @smurthas committed Mar 3, 2013
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/fitbit_client.js
View
@@ -26,11 +26,11 @@ module.exports = function (api_key, api_secret, callbackURI) {
function requestCallback(callback) {
return function (err, data, response) {
if (err) return callback(err, data);
+ var exception = null;
try {
- callback(null, response, JSON.parse(data));
- } catch (exc) {
- callback(exc, response, data);
- }
+ data = JSON.parse(data);
+ } catch (e) { exception = e; }
+ callback(exception, response, data);
};
}

0 comments on commit 5fb9f80

Please sign in to comment.