From 7472d46b2346db183640bd38dcc2cde3aaebaad4 Mon Sep 17 00:00:00 2001 From: evgeny Date: Tue, 24 Oct 2023 17:03:37 +0100 Subject: [PATCH] fix: prevent app crash during method channel call * mute IllegalStateException during `result.success` call * Log method that throws it --- .../io/ably/flutter/plugin/AblyMethodCallHandler.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/io/ably/flutter/plugin/AblyMethodCallHandler.java b/android/src/main/java/io/ably/flutter/plugin/AblyMethodCallHandler.java index cfbc2e5f6..eb9d5bea0 100644 --- a/android/src/main/java/io/ably/flutter/plugin/AblyMethodCallHandler.java +++ b/android/src/main/java/io/ably/flutter/plugin/AblyMethodCallHandler.java @@ -179,8 +179,12 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result // We don't have a handler for a method with this name so tell the caller. result.notImplemented(); } else { - // We have a handler for a method with this name so delegate to it. - handler.accept(call, result); + try { + // We have a handler for a method with this name so delegate to it. + handler.accept(call, result); + } catch (Exception e) { + Log.e(TAG, String.format("\"%s\" platform method received error during invocation", call.method), e); + } } }