简体   繁体   中英

When implementing a custom $exceptionHandler in angularJS, how do I preserve default log?

I am using a custom angularJS $exceptionHandler (to send client exceptions to my server) :

app.factory('$exceptionHandler', function() {
  return function(exception, cause) {
    //custom handling of the exception
    //...
  };
});

How do I preserve default console log ?

Default log can be preserved by using $log :

app.factory('$exceptionHandler', ['$log', function($log) {
  return function(exception, cause) {
    //custom handling of the exception
    //...
    $log.error.apply($log, arguments);
  };
}]);

More info on this blog post .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM