Skip to content

Commit 5fa7ca9

Browse files
committed
catch crashes of fetch when loading image
1 parent 9d12b8c commit 5fa7ca9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/image/loading_displaying.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,14 @@ p5.prototype.loadImage = function(path, successCallback, failureCallback) {
146146
img.src = path;
147147
}
148148
pImg.modified = true;
149-
});
149+
}).catch(e => {
150+
p5._friendlyFileLoadError(0, path);
151+
if (typeof failureCallback === 'function') {
152+
failureCallback(e);
153+
} else {
154+
console.error(e);
155+
}
156+
})
150157
return pImg;
151158
};
152159

0 commit comments

Comments
 (0)