[mob] Catch unexpected error in custom plugin

This commit is contained in:
Neeraj Gupta
2024-07-10 14:24:53 +05:30
parent 1033f26a81
commit 756954ae45

View File

@@ -197,6 +197,11 @@ class OnnxDartPlugin: FlutterPlugin, MethodCallHandler {
withContext(Dispatchers.Main) {
result.error("PREDICTION_ERROR", "Error during prediction: ${e.message}", null)
}
} catch (e: Exception) {
Log.e(TAG, "Error during prediction: ${e.message}", e)
withContext(Dispatchers.Main) {
result.error("UNHANDLED_ERROR", "Error during prediction: ${e.message}", null)
}
}
}
}