Use a combination of the two: onerrorrun a query for more details
var img= document.createElement('img');
img.src="....";
img.onerror = function(err){
$.get(img.src).fail(xhr){
})
}
Note. At the same time, CORS restrictions for cross-domain sources will obey
Or, if specified in a directive assigned to an image element:
link:function(scope, element){
element[0].onerror = function(err){
$.get(element[0].src).fail(xhr){
})
}
}