Browse files

Pass some of the error information through in the error object

  • Loading branch information...
1 parent e445a10 commit 39299f9b05d62337f0c3346f54cbfa495cfa13d7 @jhs committed Oct 29, 2011
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib.js
View
9 lib.js
@@ -97,8 +97,13 @@ exports.req_json = function req_json(opts, callback) {
return callback(er);
if(resp.statusCode < 200 || resp.statusCode >= 300)
- if(! couch_errors_are_ok)
- return callback(new Error('Couch response ' + resp.statusCode + ' to ' + opts.uri + ': ' + exports.JS(body)));
+ if(! couch_errors_are_ok) {
+ er = new Error('Couch response ' + resp.statusCode + ' to ' + opts.uri + ': ' + exports.JS(body));
+ er.statusCode = resp.statusCode;
+ for (var key in body)
+ er[key] = body[key];
+ return callback(er);
+ }
return callback(null, resp, body);
}

0 comments on commit 39299f9

Please sign in to comment.