July 2018
Intermediate to advanced
178 pages
3h 52m
English
Another way to enhance the transparency and observability of your application is to report each and every JavaScript error that occurs on the client side. Doing so is relatively simple in JavaScript; you simply need to attach a callback function to the window.onerror event, as follows:
window.onerror = function myErrorHandler(errorMsg, url, lineNumber) {alert("Error occured: " + errorMsg);}
This will simply create an alert each time an error occurs. With Angular, however, you cannot use the same simple technique—not because it is complicated, but because it requires the creation of the ne class. This new class will implement the Angular error handler interface like so:
class MyErrorHandler implements ErrorHandler {handleError(error) ...Read now
Unlock full access