Skip to content

Commit

Permalink
Ui router error listening (#82)
Browse files Browse the repository at this point in the history
* Adding listener for errors thrown by ui-router

* provide toState name in error message
  • Loading branch information
joedotjs authored Sep 18, 2016
1 parent 05f2811 commit f5fdbbc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions generated/browser/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ app.config(function ($urlRouterProvider, $locationProvider) {
});
});

// This app.run is for listening to errors broadcasted by ui-router, usually originating from resolves
app.run(function ($rootScope) {
$rootScope.$on('$stateChangeError', function (event, toState, toParams, fromState, fromParams, thrownError) {
console.info(`The following error was thrown by ui-router while transitioning to state "${toState.name}". The origin of this error is probably a resolve function:`);
console.error(thrownError);
});
});

// This app.run is for controlling access to specific states.
app.run(function ($rootScope, AuthService, $state) {

Expand Down

0 comments on commit f5fdbbc

Please sign in to comment.