From 8a163b5939f575ba39cb07c11b45653de774408d Mon Sep 17 00:00:00 2001 From: Marliana Lara Date: Fri, 23 Feb 2018 14:43:47 -0500 Subject: [PATCH] Add error handling --- awx/ui/client/src/organizations/main.js | 25 +++++++++++++++++++++---- awx/ui/client/src/projects/main.js | 12 ++++++++++-- awx/ui/client/src/templates/main.js | 24 ++++++++++++++++++++---- 3 files changed, 51 insertions(+), 10 deletions(-) diff --git a/awx/ui/client/src/organizations/main.js b/awx/ui/client/src/organizations/main.js index bb21bfb6c0..a0b179261f 100644 --- a/awx/ui/client/src/organizations/main.js +++ b/awx/ui/client/src/organizations/main.js @@ -56,13 +56,30 @@ angular.module('Organizations', [ }, resolve: { add: { - ConfigData: ['ConfigService', (ConfigService) => { - return ConfigService.getConfig().then(response => response); + ConfigData: ['ConfigService', 'ProcessErrors', (ConfigService, ProcessErrors) => { + return ConfigService.getConfig() + .then(response => response) + .catch(({data, status}) => { + ProcessErrors(null, data, status, null, { + hdr: 'Error!', + msg: 'Failed to get config. GET returned status: ' + + 'status: ' + status + }); + }); + }] }, edit: { - ConfigData: ['ConfigService', (ConfigService) => { - return ConfigService.getConfig().then(response => response); + ConfigData: ['ConfigService', 'ProcessErrors', (ConfigService, ProcessErrors) => { + return ConfigService.getConfig() + .then(response => response) + .catch(({data, status}) => { + ProcessErrors(null, data, status, null, { + hdr: 'Error!', + msg: 'Failed to get config. GET returned status: ' + + 'status: ' + status + }); + }); }], InstanceGroupsData: ['$stateParams', 'Rest', 'GetBasePath', 'ProcessErrors', function($stateParams, Rest, GetBasePath, ProcessErrors){ diff --git a/awx/ui/client/src/projects/main.js b/awx/ui/client/src/projects/main.js index c997f2a5c0..94eee1de34 100644 --- a/awx/ui/client/src/projects/main.js +++ b/awx/ui/client/src/projects/main.js @@ -48,8 +48,16 @@ angular.module('Projects', []) }); } ], - ConfigData: ['ConfigService', (ConfigService) => { - return ConfigService.getConfig().then(response => response); + ConfigData: ['ConfigService', 'ProcessErrors', (ConfigService, ProcessErrors) => { + return ConfigService.getConfig() + .then(response => response) + .catch(({data, status}) => { + ProcessErrors(null, data, status, null, { + hdr: 'Error!', + msg: 'Failed to get config. GET returned status: ' + + 'status: ' + status + }); + }); }] }; diff --git a/awx/ui/client/src/templates/main.js b/awx/ui/client/src/templates/main.js index 21ec6ce323..144d597e2e 100644 --- a/awx/ui/client/src/templates/main.js +++ b/awx/ui/client/src/templates/main.js @@ -130,8 +130,16 @@ angular.module('templates', [surveyMaker.name, jobTemplates.name, labels.name, p }); }); }], - ConfigData: ['ConfigService', (ConfigService) => { - return ConfigService.getConfig().then(response => response); + ConfigData: ['ConfigService', 'ProcessErrors', (ConfigService, ProcessErrors) => { + return ConfigService.getConfig() + .then(response => response) + .catch(({data, status}) => { + ProcessErrors(null, data, status, null, { + hdr: 'Error!', + msg: 'Failed to get config. GET returned status: ' + + 'status: ' + status + }); + }); }] } } @@ -264,8 +272,16 @@ angular.module('templates', [surveyMaker.name, jobTemplates.name, labels.name, p }); }); }], - ConfigData: ['ConfigService', (ConfigService) => { - return ConfigService.getConfig().then(response => response); + ConfigData: ['ConfigService', 'ProcessErrors', (ConfigService, ProcessErrors) => { + return ConfigService.getConfig() + .then(response => response) + .catch(({data, status}) => { + ProcessErrors(null, data, status, null, { + hdr: 'Error!', + msg: 'Failed to get config. GET returned status: ' + + 'status: ' + status + }); + }); }] } }