As I can not comment because I am a new user, I am posting this question as separate one. This question is related to Can I catch http errors when using jQuery to modify styles?
Let us say I have a HTML5 REST based application created using Javascript, JQuery and AngularJS frameworks.
In the below snippet I have a background-image URL, if the image is not found I will get a 404 error. The snippet is dynamically generated, based on some JSON data coming from the external API. In some cases I might be having broken URLs for images.
What I am looking for is to handle all such errors globally and avoid calling one error type on each element that triggered the error.
<div style="background-image: url(http://somedomain.com/uploads/images/qq);"></div>
window.onerror = function () { console.log("Something gone wrong"); }andwindow.addEventListener("error", function (e) { console.log("Something gone wrong"); console.log(e.error.message, "from", e.error.stack); });