Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,10 @@ class ImageEditorModuleImpl(private val reactContext: ReactApplicationContext) {
copyExif(reactContext, Uri.parse(uri), tempFile)
}
promise.resolve(getResultMap(tempFile, cropped, mimeType, includeBase64))
} catch (e: Exception) {
} catch (e: Throwable) {
// Errors (e.g. OutOfMemoryError while decoding) must be turned into a rejection
// too: they don't extend Exception and would otherwise escape the coroutine and
// crash the app, leaving the promise unsettled.
promise.reject(e)
}
}
Expand Down Expand Up @@ -219,7 +222,10 @@ class ImageEditorModuleImpl(private val reactContext: ReactApplicationContext) {
BitmapRegionDecoder.newInstance(it)
} else {
@Suppress("DEPRECATION") BitmapRegionDecoder.newInstance(it, false)
} ?: throw Error("Could not create bitmap decoder. Uri: $uri")
}
?: throw JSApplicationIllegalArgumentException(
"Could not create bitmap decoder. Uri: $uri"
)

val imageHeight: Int = decoder.height
val imageWidth: Int = decoder.width
Expand Down Expand Up @@ -283,7 +289,10 @@ class ImageEditorModuleImpl(private val reactContext: ReactApplicationContext) {
BitmapRegionDecoder.newInstance(it)
} else {
@Suppress("DEPRECATION") BitmapRegionDecoder.newInstance(it, false)
} ?: throw Error("Could not create bitmap decoder. Uri: $uri")
}
?: throw JSApplicationIllegalArgumentException(
"Could not create bitmap decoder. Uri: $uri"
)

val orientation = getOrientation(reactContext, Uri.parse(uri))
val (x, y) =
Expand Down
Loading