Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
mark err.response as non-enumerable to avoid clutter
Browse files Browse the repository at this point in the history
Fix #34.
  • Loading branch information
sylvaingi authored and benesch committed Aug 11, 2016
1 parent 36a46ed commit f714fa9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ function makeModule(Promise) {
return new Promise(function (resolve, reject) {
self.end(function (err, res) {
if (err) {
err.response = res;
// Attach response to error object so that details about the failure
// (e.g., the response body) can be accessed by a `.catch` handler
// (#30). Use `Object.defineProperty` so that `.response` is
// non-enumerable; otherwise, the error message is lost in the sea of
// the response object (#34).
Object.defineProperty(err, 'response', { value: res });
reject(err);
return;
}
Expand Down

0 comments on commit f714fa9

Please sign in to comment.