check for object existence before searching for key on that object

to resolve some console errors in regards to http  error handling
This commit is contained in:
Jared Tabor 2015-10-14 09:14:44 -07:00
parent 1bbd5fbe0a
commit ff121a56c1
2 changed files with 4 additions and 4 deletions

View File

@ -21,7 +21,7 @@
return config;
},
responseError: function(rejection){
if( !_.isEmpty(rejection.data.detail) && rejection.data.detail === "Maximum per-user sessions reached"){
if( rejection.data && !_.isEmpty(rejection.data.detail) && rejection.data.detail === "Maximum per-user sessions reached"){
$rootScope.sessionTimer.expireSession('session_limit');
return $q.reject(rejection);
}

View File

@ -203,11 +203,11 @@ angular.module('Utilities', ['RestServices', 'Utilities', 'sanitizeFilter'])
$rootScope.sessionTimer.expireSession('idle');
}
$location.url('/login');
} else if (data.non_field_errors) {
} else if (data && data.non_field_errors) {
Alert('Error!', data.non_field_errors);
} else if (data.detail) {
} else if (data && data.detail) {
Alert(defaultMsg.hdr, defaultMsg.msg + ' ' + data.detail);
} else if (data.__all__) {
} else if (data && data.__all__) {
if (typeof data.__all__ === 'object' && Array.isArray(data.__all__)) {
Alert('Error!', data.__all__[0]);
}