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

Commit

Permalink
use href of response context for url reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert committed Jul 29, 2016
1 parent b2a8458 commit f18e40d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/ds/RequestExecutor.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,15 @@ RequestExecutor.prototype.execute = function executeRequest(req, callback) {
this.requestAuthenticator.authenticate(options);

request(options, function onRequestResult(err, response, body) {
var responseContext = this;
if (err) {
var wrapper = new Error('Unable to execute http request ' + req.method + ' ' + req.uri + ': ' + err.message);
wrapper.inner = err;
return callback(wrapper, null);
}

if (response.statusCode > 399) {
return callback(new ResourceError(body || {status:response.statusCode}, {url: req.uri, method: req.method}), null);
return callback(new ResourceError(body || {status:response.statusCode}, {url: responseContext.href, method: req.method}), null);
}

if (response.statusCode === 201){
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 @@ -107,6 +107,7 @@ describe('ds:', function () {
err.should.be.an.instanceof(ResourceError);
expect(body).to.be.null;
cbSpy.should.have.been.calledOnce;
expect(err.url).to.equal(mockHost + uri);
done();
}
cbSpy = sinon.spy(cb);
Expand Down

0 comments on commit f18e40d

Please sign in to comment.