react-native-image-resizer
react-native-image-resizer copied to clipboard
fix: don't throw outside promise creation
When a function returns a promise all its error handling should result in promise rejections.
For instance this could would have an exception thrown when not using await
and proper try...catch
blocks:
// on iOS
createResizedImage(..., "webp").catch(console.error.bind(console))
This would not print the error but instead throw an exception up the chain.
With the changes in this commit proper exception handling is taken care of.
Both of this works now:
// on iOS
createResizedImage(..., "webp").catch(console.error.bind(console))
// or
try {
await createResizedImage(..., "webp")
} catch(error) {
console.error(error)
}