Unable to catch image load error/exception
<p>I want to catch errors in loading images. Unfortunately I am not able to catch them, I get an error in console like this.</p>

<pre><code>Failed to load resource file:///C:/Users/Ankur/Dropbox/Public/InteractiveGuide/Images/copyright_symbol.jpg
</code></pre>

<p>I am using both try catch blocks as well as .onerror(). This is the code.</p>

<pre><code>function preloadImages(arr)
{
    var newimages=[], loadedImages=0, dir="./Images/";
    var arr = (typeof arr!="object")?[arr]:arr;
    for(var i=0; i&lt;arr.length; i++)
    {
        try
        {
            newimages[i]=new Image();
            newimages[i].src = dir+arr[i];
            newimages[i].onload = function()
            {
                loadedImages++;
                if(loadedImages==arr.length)
                {
                    iniScene();
                }
            }
            newimages.onerror = function()
            {
                console.log("Error loading image: "+arr[i]);
            }
        }
        catch(ex)
        {
            console.log("Image Loading Error: "+ex);
        }
    }
}
</code></pre>

<p>How to catch the error properly?</p>
