We are collecting error events using $exceptionHandler, inside the $exceptionHandler callback
callback we store exception infomration in a global array.
But when we iterate the exception
object manually it shows data, in the debugger it shows data also but when we use JSON.stringify(exception)
it returns just {}
braces.
What may be the problem ?
My code inside the $exceptionHandler
callback :
angular.module('myApp').factory('$exceptionHandler', ['$log', '$injector', function ($log, $injector) {
var $rootScope;
return function myExceptionHandler(exception, cause) {
debugger
$rootScope = $rootScope || $injector.get('$rootScope');
var TAG = 'myExceptionHandlerTAG';
var expJson = JSON.stringify(exception);
var eve = {
event : "error",
params : { user_id : user_id,
role : role,
time : new Date().getTime(),
code_name: navigator.appCodeName,
name: navigator.appName ,
version: navigator.appVersion ,
cookie: navigator.cookieEnabled,
language: navigator.language,
on_line: navigator.onLine,
platform: navigator.platform,
user_agent: navigator.userAgent,
exception: expJson,
cause: cause },
source : "web_app"
};
$rootScope.events_json.push(eve);
$log.error(eve);
};
}]);
Update:
Contents of exception
object in the debugger:
Contents of expJson
object in the debugger:
Also, I am not modifying the exception
object in the code anywhere except assigning to other variables.