Add error handling

This commit is contained in:
Marliana Lara 2018-02-23 14:43:47 -05:00
parent 23300003ab
commit 8a163b5939
No known key found for this signature in database
GPG Key ID: 38C73B40DFA809EE
3 changed files with 51 additions and 10 deletions

View File

@ -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){

View File

@ -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
});
});
}]
};

View File

@ -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
});
});
}]
}
}