The AngularJS $exceptionHandler service allows you-to-catch and handle unanticipated JavaScript errors in a meaningful it .
so when application are under building process, can create a $exceptionHandler service to log out the Uncatch exception .
Angular.module (' app ', []). Factory (' $exceptionHandler ',function($injector) {return function(exception, cause) {var$rootScope = $injector. Get (' $rootScope '); $rootScope. Errors= $rootScope. Errors | | []; $rootScope. Errors.push (Exception.Message); Console.log ($rootScope. Errors); }}). Run (function($http) {functiononsuccess (Result) {Console.log (' Hooray data! '); Console.log (Result.data.length,' Repos found '); Result.count (); //This was no count () method on the result object. } functionOnFailure (info) {Console.log (' Boo Error:('); Console.log (info); } $http. Get (' Https://api.github.com/users/bclinkinbeard/repos '). Then (onsuccess, onfailure); //We can catch $http return failure but there could is some uncatch failure in some place});
[AngularJS] Catching Errors with $exceptionHandler