Handle errors with ProcessErrors

This commit is contained in:
Marliana Lara 2017-10-19 14:59:49 -04:00
parent cee81e9df6
commit 32da686724
No known key found for this signature in database
GPG Key ID: 38C73B40DFA809EE
6 changed files with 32 additions and 21 deletions

View File

@ -275,8 +275,11 @@ export default
}));
$scope.credential_types = credential_types;
})
.catch( (error) => {
console.log(error);
.catch(({data, status}) => {
ProcessErrors($scope, data, status, null, {
hdr: 'Error!',
msg: 'Failed to get credential types. GET status: ' + status
});
});
// Figure out which step the user needs to start on

View File

@ -116,7 +116,7 @@
function retrieveStatus(id) {
setTimeout(function() {
var url = GetBasePath('notifications') + id;
let url = GetBasePath('notifications') + id;
Rest.setUrl(url);
Rest.get()
.then(function(res) {
@ -142,9 +142,12 @@
}
})
.catch( (error) => {
console.log(error);
})
.catch(({data, status}) => {
ProcessErrors($scope, data, status, null, {
hdr: 'Error!',
msg: 'Failed to get ' + url + '. GET status: ' + status
});
});
}, 5000);
}
};

View File

@ -61,7 +61,7 @@ export default
ParentObject: ['$stateParams', 'Rest', 'GetBasePath', function($stateParams, Rest, GetBasePath){
let path = `${GetBasePath('job_templates')}${$stateParams.id}`;
Rest.setUrl(path);
return Rest.get(path).then(response => response.data)
return Rest.get(path).then(response => response.data);
}],
UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q',
function(Rest, GetBasePath, $stateParams, $q) {
@ -152,7 +152,7 @@ export default
ParentObject: ['$stateParams', 'Rest', 'GetBasePath', function($stateParams, Rest, GetBasePath){
let path = `${GetBasePath('workflow_job_templates')}${$stateParams.id}`;
Rest.setUrl(path);
return Rest.get(path).then(response => response.data)
return Rest.get(path).then(response => response.data);
}],
UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q',
function(Rest, GetBasePath, $stateParams, $q) {
@ -242,7 +242,7 @@ export default
ParentObject: ['$stateParams', 'Rest', 'GetBasePath', function($stateParams, Rest, GetBasePath){
let path = `${GetBasePath('projects')}${$stateParams.id}`;
Rest.setUrl(path);
return Rest.get(path).then(response => response.data)
return Rest.get(path).then(response => response.data);
}],
UnifiedJobsOptions: ['Rest', 'GetBasePath', '$stateParams', '$q',
function(Rest, GetBasePath, $stateParams, $q) {

View File

@ -22,7 +22,8 @@ export default
if (data.actions.POST) {
canAddVal.resolve({canAdd: true, options: data});
} else {
canAddVal.resolve({canAdd: false}) }
canAddVal.resolve({canAdd: false});
}
Wait("stop");
});

View File

@ -99,8 +99,7 @@ export default
}
})
.catch( (error) => {
console.log(error);
if (status_code === 403) {
if (error.status_code === 403) {
/* user doesn't have access to see the project, no big deal. */
$scope.disablePlaybookBecausePermissionDenied = true;
} else {
@ -144,9 +143,12 @@ export default
.then(function(){
Wait('stop');
})
.catch( (error) => {
console.log(error);
})
.catch(({data, status}) => {
ProcessErrors($scope, data, status, null, {
hdr: 'Error!',
msg: 'Call failed. Returned status: ' + status
});
});
}
}
});

View File

@ -210,13 +210,15 @@ export default ['$scope', '$rootScope',
$state.go('templates.editJobTemplate', {job_template_id: results.id}, {reload: true});
}
})
.catch((error)=> {
console.log(error);
})
.catch(({data, status}) => {
ProcessErrors($scope, data, status, null, {
hdr: 'Error!',
msg: 'Call failed. Return status: ' + status
});
});
})
.catch((error) => {
console.log(error);
ProcessErrors($rootScope, error, status, null, {hdr: 'Error!',
.catch(({data, status}) => {
ProcessErrors($rootScope, data, status, null, {hdr: 'Error!',
msg: 'Call failed. Return status: '+ status});
});
}