From e0efc11ef56955ab623c0baccb5826b335c803a9 Mon Sep 17 00:00:00 2001 From: Joe Fiorini Date: Wed, 21 Jan 2015 12:49:37 -0500 Subject: [PATCH] Add error handling to retrieval service --- awx/ui/static/js/services/job-status-graph-data.js | 12 ++++++++++++ .../unit/services/job-status-graph-data-test.js | 14 +++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/awx/ui/static/js/services/job-status-graph-data.js b/awx/ui/static/js/services/job-status-graph-data.js index 638774177b..037747c496 100644 --- a/awx/ui/static/js/services/job-status-graph-data.js +++ b/awx/ui/static/js/services/job-status-graph-data.js @@ -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; }); }); }, diff --git a/awx/ui/tests/unit/services/job-status-graph-data-test.js b/awx/ui/tests/unit/services/job-status-graph-data-test.js index e36014b500..4cb80df2a4 100644 --- a/awx/ui/tests/unit/services/job-status-graph-data-test.js +++ b/awx/ui/tests/unit/services/job-status-graph-data-test.js @@ -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() { - }); - });