I'm writing an application in JavaScript that should create a new image. Sometimes it fails. I was able to detect the times when it does by attaching an image.onerror
event listener. Question is: How may I learn what error occured - what parameters does the error object for images bring? So far I only found out that
image.onerror = function (errorMsg, url, lineNumber, column, errorObj) {
console.log('Error: ' + errorMsg + ' Script: ' + url + ' Line: ' + lineNumber
+ ' Column: ' + column + ' StackTrace: ' + errorObj);
}
which I got from: javascript: how to display script errors in a popup alert?
returns Error: [object Event] Script: undefined Line: undefined Column: undefined StackTrace: undefined
and in the error object I couldn't find anything related to message or error code.
AFAIK the image.onerror handler will receive a single Event parameter that doesn't contain any info on the cause of the error.