I am currently using AngularJS and attempting to capture all errors across all pages. However, I am encountering an issue where it does not catch errors in some instances. For example, when I trigger a ReferenceError in one of the controllers, it is not being caught.
$rootScope.$on("$stateChangeStart", function() {
window.onerror = function( msg, url, line, col, error ) {
var extra = !col ? '' : '\ncolumn: ' + col;
extra += !error ? '' : '\nerror: ' + error;
var data = {
msg : msg,
url : url,
line: line + extra
}
alert('error');
var suppressErrorAlert = true;
return suppressErrorAlert;
};
}
What steps can I take to resolve this issue and ensure that all errors are properly captured?