Skip to content
This repository has been archived by the owner on Dec 12, 2018. It is now read-only.

Commit

Permalink
fix issue with undefined req.method and stack being cleared
Browse files Browse the repository at this point in the history
  • Loading branch information
typerandom committed Jan 18, 2016
1 parent 9bf6858 commit b318ca1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/ds/RequestExecutor.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,23 @@ RequestExecutor.prototype.execute = function executeRequest(req, callback) {
throw new Error('request.uri field is required.');
}

//don't override the defaults: ensure that the options arg is request-specific:
// Don't override the defaults: ensure that the options arg is request-specific.
var options = utils.shallowCopy(this.options, {});

if (req.method) { //defaults to GET
options.method = req.method;
}
req.method = req.method || 'GET';

options.method = req.method;
options.uri = this.qualify(req.uri);

if (req.query) {
options.qs = req.query;
}

if (req.body && req.body.form){
options.form = req.body.form;
}
else if (req.body) {
} else if (req.body) {
options.body = req.body;
options.json = true; //all Stormpath resources are JSON
options.json = true; // All Stormpath resources are JSON
}

this.requestAuthenticator.authenticate(options);
Expand All @@ -92,7 +93,6 @@ RequestExecutor.prototype.execute = function executeRequest(req, callback) {
if (err) {
var wrapper = new Error('Unable to execute http request ' + req.method + ' ' + req.uri + ': ' + err.message);
wrapper.inner = err;
wrapper.stack = '';
return callback(wrapper, null);
}

Expand Down
1 change: 1 addition & 0 deletions test/sp.ds.requestExecutor_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ describe('ds:', function () {
err.should.be.an.instanceof(Error);

err.should.have.property('stack')
.that.is.not.empty.and
.that.is.not.null.and
.that.is.not.undefined;

Expand Down

0 comments on commit b318ca1

Please sign in to comment.