Add error handling to retrieval service

This commit is contained in:
Joe Fiorini 2015-01-21 12:49:37 -05:00
parent d7a150befe
commit e0efc11ef5
2 changed files with 23 additions and 3 deletions

View File

@ -22,6 +22,18 @@ function JobStatusGraphData(Rest, getBasePath, processErrors, $rootScope, $q) {
$rootScope.
$broadcast('DataReceived:JobStatusGraph',
result);
return result;
}).catch(function(response) {
var errorMessage = 'Failed to get: ' + url + ' GET returned: ' + status;
ProcessErrors(null,
response.data,
response.status,
null, {
hdr: 'Error!',
msg: errorMessage
});
return response;
});
});
},

View File

@ -71,6 +71,17 @@ describe('Job Status Graph Data Service', function() {
return expect(result).to.eventually.equal(firstResult);;
});
it('processes errors through error handler', function() {
var expected = { data: "error", status: "bad" };
var actual = jobStatusGraphData.get();
restStub.fail(expected);
flushPromises();
return expect(actual).to.be.rejectedWith(expected);
});
it('broadcasts event when data is received', function() {
var expected = "value";
var result = q.defer();
@ -88,7 +99,4 @@ describe('Job Status Graph Data Service', function() {
return expect(result.promise).to.eventually.equal(expected);
});
xit('processes errors through error handler', function() {
});
});