Skip to content

Commit

Permalink
Display error message when routing error
Browse files Browse the repository at this point in the history
  • Loading branch information
fzaninotto committed Apr 15, 2015
1 parent b74a8ba commit d8a686d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/javascripts/ng-admin/Main/run/ErrorHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@
define(function () {
'use strict';

function errorHandler($rootScope, $state, $location) {
function errorHandler($rootScope, $state, notification) {
$rootScope.$on("$stateChangeError", function handleError(event, toState, toParams, fromState, fromParams, error) {
if (error.status == 404) {
$state.go('ma-404');
event.preventDefault();
} else {
notification.log('State change error: ' + error.message, { addnCls: 'humane-flatty-error' });
throw error;
}
});
}

errorHandler.$inject = ['$rootScope', '$state', '$location'];
errorHandler.$inject = ['$rootScope', '$state', 'notification'];

return errorHandler;
});
4 changes: 4 additions & 0 deletions src/javascripts/ng-admin/Main/run/Loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ define(function () {
progression.done();
$window.scrollTo(0, 0);
});

$rootScope.$on("$stateChangeError", function() {
progression.done();
});
}

loader.$inject = ['$rootScope', '$window', 'progression'];
Expand Down

0 comments on commit d8a686d

Please sign in to comment.