diff --git a/shared/fetcher.js b/shared/fetcher.js index 4ff6adf3..26d54c8b 100644 --- a/shared/fetcher.js +++ b/shared/fetcher.js @@ -187,6 +187,7 @@ Fetcher.prototype.fetchFromApi = function(spec, options, callback) { respOutput = JSON.stringify(resp); err = new Error("ERROR fetching model '" + fetcher.modelUtils.modelName(model.constructor) + "' with options '" + JSON.stringify(options) + "'. Response: " + respOutput); err.status = resp.status; + err.statusText = resp.statusText; err.body = body; callback(err); } diff --git a/shared/syncer.js b/shared/syncer.js index 00d2800c..8a45d187 100644 --- a/shared/syncer.js +++ b/shared/syncer.js @@ -48,7 +48,8 @@ function clientSync(method, model, options) { } resp = { body: body, - status: xhr.status + status: xhr.status, + statusText: xhr.statusText }; error(resp); } diff --git a/test/shared/syncer.test.js b/test/shared/syncer.test.js index bfb8d68f..8d7f148f 100644 --- a/test/shared/syncer.test.js +++ b/test/shared/syncer.test.js @@ -255,6 +255,7 @@ describe('syncer', function() { fakeXhr = { responseText: '{"foo": "bar"}', status: 418, + statusText: 0, getResponseHeader: sinon.stub() }; options.error = syncErrorHandler; @@ -264,7 +265,8 @@ describe('syncer', function() { it('should call the original error handler with status and body', function () { var expectedResponse = { body: fakeXhr.responseText, - status: fakeXhr.status + status: fakeXhr.status, + statusText: fakeXhr.statusText }; syncer.clientSync.call(model, 'read', model, options); @@ -276,7 +278,8 @@ describe('syncer', function() { it('should parse the payload if content-type is "application/json"', function () { var expectedResponse = { body: JSON.parse(fakeXhr.responseText), - status: fakeXhr.status + status: fakeXhr.status, + statusText: fakeXhr.statusText, }; fakeXhr.getResponseHeader.withArgs('content-type').returns('application/json'); @@ -334,6 +337,7 @@ describe('syncer', function() { fakeXhr = { responseText: '{"foo": "bar"}', status: 418, + statusText: 0, getResponseHeader: sinon.stub() }; options.error = syncErrorHandler; @@ -343,7 +347,8 @@ describe('syncer', function() { it('should call the original error handler with status and body', function () { var expectedResponse = { body: fakeXhr.responseText, - status: fakeXhr.status + status: fakeXhr.status, + statusText: fakeXhr.statusText }; syncer.clientSync.call(model, 'read', model, options); @@ -355,7 +360,8 @@ describe('syncer', function() { it('should parse the payload if content-type is "application/json"', function () { var expectedResponse = { body: JSON.parse(fakeXhr.responseText), - status: fakeXhr.status + status: fakeXhr.status, + statusText: fakeXhr.statusText }; fakeXhr.getResponseHeader.withArgs('content-type').returns('application/json');