Adds error catch block to credentials resolve

Catches the case where a user doesn't have permission to a credential
This commit is contained in:
Jared Tabor 2018-07-13 13:54:00 -07:00
parent 9a44f6d13d
commit 7dbdff2aa7
No known key found for this signature in database
GPG Key ID: CC50E67C506270C9

View File

@ -7,7 +7,16 @@ const MODULE_NAME = 'at.features.credentials';
const addEditTemplate = require('~features/credentials/add-edit-credentials.view.html');
function CredentialsResolve ($q, $stateParams, Me, Credential, CredentialType, Organization) {
function CredentialsResolve (
$q,
$stateParams,
Me,
Credential,
CredentialType,
Organization,
ProcessErrors,
strings
) {
const id = $stateParams.credential_id;
const promises = {
@ -43,6 +52,12 @@ function CredentialsResolve ($q, $stateParams, Me, Credential, CredentialType, O
return models;
});
}).catch(({ data, status, config }) => {
ProcessErrors(null, data, status, null, {
hdr: strings.get('error.HEADER'),
msg: strings.get('error.CALL', { path: `${config.url}`, status })
});
return $q.reject();
});
}
@ -52,7 +67,9 @@ CredentialsResolve.$inject = [
'MeModel',
'CredentialModel',
'CredentialTypeModel',
'OrganizationModel'
'OrganizationModel',
'ProcessErrors',
'CredentialsStrings'
];
function CredentialsRun ($stateExtender, legacy, strings) {