Skip to content

Instantly share code, notes, and snippets.

@xcarpentier
Created December 15, 2014 15:35
Show Gist options
  • Save xcarpentier/4c25ab16ec199ebfbe2e to your computer and use it in GitHub Desktop.
Save xcarpentier/4c25ab16ec199ebfbe2e to your computer and use it in GitHub Desktop.
/* recommandé */
function handleRoutingErrors() {
/**
* Annulation de route :
* Lors d'une erreur de routing aller au dashboard.
* Fournir une clause de sortie si il essaye deux fois.
*/
$rootScope.$on('$routeChangeError',
function (event, current, previous, rejection) {
var destination = (current && (current.title || current.name || current.loadedTemplateUrl)) ||
'unknown target';
var msg = 'Error routing to ' + destination + '. ' + (rejection.msg || '');
/**
* Optionellement logguez en utilisant un service custom ou $log.
* (N'oubliez pas d'injecter le service custom)
*/
logger.warning(msg, [current]);
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment