My application is equipped with a functional $exceptionHandler
. It effectively captures angularJS errors and sends the error data to my email for analysis. However, there seems to be an issue where it fails to capture the HTML element responsible for triggering the $scope function, as well as the input data that led to the error.
To illustrate further, my app consists of multiple pages sharing the same controller, which in turn utilize identical functions. For instance, the validation function monitorLength
is used across various pages where users input data. It might be on an
<input type='tel' ng-keydown="monitorLength($event,this.id,phoneLength,1)">
field, or on an <input type='number' ng-keydown="monitorLength($event,this.id,postalLength,2)">
field, or even called by another function.
However, when an error occurs, the displayed information is insufficient for identifying the specific page/template/input field associated with the function or understanding the input causing the function to fail. The error message typically resembles this:
Exception: undefined is not an object (evaluating 'mLengths.length')
Stack: ionic://localhost/js/controllers.js:1291:47
In order to enhance error handling, how can I retrieve A) the HTML element that invoked the function, and B) the input data passed to the function resulting in the error?
Considering the example provided, here is the implementation of the monitorLength function:
// Function Implementation Here
And below is the configuration of my error/exception handler:
// Exception Handler Configuration Here