From f5d47f97bf59dab2b4f7ff46c82efe80b0d827c6 Mon Sep 17 00:00:00 2001 From: Gaurav Goel Date: Fri, 28 Jun 2024 10:34:15 +0530 Subject: [PATCH] code refactored for User cancellation during login Signed-off-by: Gaurav Goel --- .../flutter/web3auth_flutter/Web3AuthFlutterPlugin.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/android/src/main/kotlin/com/web3auth/flutter/web3auth_flutter/Web3AuthFlutterPlugin.kt b/android/src/main/kotlin/com/web3auth/flutter/web3auth_flutter/Web3AuthFlutterPlugin.kt index 9f3547e..a180923 100644 --- a/android/src/main/kotlin/com/web3auth/flutter/web3auth_flutter/Web3AuthFlutterPlugin.kt +++ b/android/src/main/kotlin/com/web3auth/flutter/web3auth_flutter/Web3AuthFlutterPlugin.kt @@ -78,7 +78,11 @@ class Web3AuthFlutterPlugin : FlutterPlugin, ActivityAware, MethodCallHandler, launch(Dispatchers.Main) { result.notImplemented() } } catch (e: Throwable) { launch(Dispatchers.Main) { - result.error("error", e.message, e.localizedMessage) + if(e.message == "User Cancelled") { + result.error("UserCancelledException", e.message, e.localizedMessage) + } else { + result.error("error", e.message, e.localizedMessage) + } } } } @@ -118,7 +122,7 @@ class Web3AuthFlutterPlugin : FlutterPlugin, ActivityAware, MethodCallHandler, } catch (e: NotImplementedError) { throw Error(e) } catch (e: Throwable) { - throw Error(e) + throw Error("User Cancelled") } }