Skip to content

Commit

Permalink
Show error information on console state change fail
Browse files Browse the repository at this point in the history
Also fix the file formatting for events.js
  • Loading branch information
ammendonca committed Apr 6, 2018
1 parent b2d1a00 commit c15b9c6
Showing 1 changed file with 25 additions and 28 deletions.
Expand Up @@ -2,33 +2,30 @@

angular.module('rcApp').controller('EventsCtrl', function ($rootScope, $state, Notifications, urlStateTracker, $location) {

$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams, options){
//console.log("switching states: " + fromState.name + " -> " + toState.name);
});
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams, options) {
// console.log('switching states: ' + fromState.name + ' -> ' + toState.name);
});

$rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error){
event.preventDefault();
console.log("Error switching state: " + fromState.name + " -> " + toState.name);
// see AuthService.checkAccess() for error definitions
if (error == "MISSING_ACCOUNT_SID")
$state.go("public.login");
else
if (error == 'RESTCOMM_AUTH_FAILED' || error == 'RESTCOMM_NOT_AUTHENTICATED') {
//Notifications.error('Unauthorized access');
urlStateTracker.remember($location);
$state.go("public.login");
} else
if (error == 'RESTCOMM_ACCOUNT_NOT_INITIALIZED') {
$state.go('public.uninitialized');
} else
if (error == 'ACCOUNT_ALREADY_INITIALIZED') {
$state.go('restcomm.dashboard');
} else
if (error == 'UNKWNOWN_ERROR') {
console.log('internal error');
}
});
$rootScope.$on('$stateChangeError', function(event, toState, toParams, fromState, fromParams, error) {
event.preventDefault();
console.error('Error switching state: ' + fromState.name + ' -> ' + toState.name, error);
// see AuthService.checkAccess() for error definitions
if (error === 'MISSING_ACCOUNT_SID') {
$state.go('public.login');
}
else if (error === 'RESTCOMM_AUTH_FAILED' || error === 'RESTCOMM_NOT_AUTHENTICATED') {
// Notifications.error('Unauthorized access');
urlStateTracker.remember($location);
$state.go('public.login');
}
else if (error === 'RESTCOMM_ACCOUNT_NOT_INITIALIZED') {
$state.go('public.uninitialized');
}
else if (error === 'ACCOUNT_ALREADY_INITIALIZED') {
$state.go('restcomm.dashboard');
}
else if (error === 'UNKWNOWN_ERROR') {
console.error('internal error');
}
});
});



0 comments on commit c15b9c6

Please sign in to comment.