Permalink
Browse files

capture error messages when updating rules

  • Loading branch information...
1 parent 49f7e3d commit 2ff8b37928af8f558cae9eddf8181459ac8afbd6 @demian85 committed Jul 31, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 lib/rules.js
View
@@ -27,7 +27,11 @@ LiveRules.prototype.add = function(rules, cb) {
}, function(err, response, body) {
if (err) cb(err);
else if (response.statusCode >= 200 && response.statusCode < 300) cb();
- else cb(new Error('Unable to add rules. Request failed with status code: ' + response.statusCode));
+ else {
+ var errStr = 'Unable to add rules. Request failed with status code: ' + response.statusCode;
+ if (body && body.error) errStr += '.\n' + body.error.message;
+ cb(new Error(errStr));
+ }
});
};

0 comments on commit 2ff8b37

Please sign in to comment.