Return error from method channel

This commit is contained in:
Ming Ming 2021-04-30 23:05:54 +08:00
parent 22b607f89c
commit 02ff3a0d70

View file

@ -34,8 +34,12 @@ class MediaStoreChannelHandler(activity: Activity)
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
if (call.method == "saveFileToDownload") {
saveFileToDownload(call.argument<String>("fileName")!!,
call.argument<ByteArray>("content")!!, result)
try {
saveFileToDownload(call.argument<String>("fileName")!!,
call.argument<ByteArray>("content")!!, result)
} catch (e: Throwable) {
result.error("systemException", e.message, null)
}
} else {
result.notImplemented()
}