Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed error handling when image format is invalid
  • Loading branch information
bpisano committed Jan 23, 2022
1 parent 00b7154 commit 443806f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions resemble.js
Expand Up @@ -316,10 +316,14 @@ var isNode = function () {
hiddenImage.setAttribute("crossorigin", "anonymous");
}

hiddenImage.onerror = function (err) {
hiddenImage.onerror = function (event) {
hiddenImage.onload = null;
hiddenImage.onerror = null; // fixes pollution between calls
images.push({ error: err ? err + "" : "Image load error." });
if (event.path && event.path[0]) {
images.push({ error: `Failed to load image: ${event.path[0].currentSrc}`})
} else {
images.push({ error: err ? `Failed to load image with error: ${event}` : "Failed to load image. Unknown error." });
}
callback();
};

Expand Down

0 comments on commit 443806f

Please sign in to comment.