Skip to content

Commit 8e25a70

Browse files
committed
fix: uncaught exceptions, still need to reject promise
Revert "fix: uncaught exceptions, still need to reject promise" This reverts commit 5faa5f6. fix: catch uncaught error in scale transformation fix: resolveWrapper never rejected errors Revert "fix: catch uncaught error in scale transformation" This reverts commit 8e93865. fix: catch any transformation error fix: prettier
1 parent b14e2df commit 8e25a70

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

js/load-image.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
// Not using Promises
4646
if (resolve) resolve(img, data)
4747
return
48+
} else if (img instanceof Error) {
49+
reject(img)
50+
return
4851
}
4952
data = data || {} // eslint-disable-line no-param-reassign
5053
data.image = img
@@ -159,10 +162,15 @@
159162

160163
loadImage.onload = function (img, event, file, url, callback, options) {
161164
revokeHelper(url, options)
162-
loadImage.transform(img, options, callback, file, {
163-
originalWidth: img.naturalWidth || img.width,
164-
originalHeight: img.naturalHeight || img.height
165-
})
165+
166+
try {
167+
loadImage.transform(img, options, callback, file, {
168+
originalWidth: img.naturalWidth || img.width,
169+
originalHeight: img.naturalHeight || img.height
170+
})
171+
} catch (error) {
172+
callback(error)
173+
}
166174
}
167175

168176
loadImage.createObjectURL = function (file) {

0 commit comments

Comments
 (0)