From cc9826077540dfdcd12ebe0f57470e7419f8c922 Mon Sep 17 00:00:00 2001 From: AuroraHuang22 Date: Thu, 26 Sep 2024 16:42:57 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=A5=85=20Throw=20connection=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/AppHeader.vue | 19 +++++++++++++++++-- layouts/wallet.vue | 17 +++++++++++++++-- pages/auth/redirect.vue | 8 ++++++-- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/components/AppHeader.vue b/components/AppHeader.vue index de9b2ee4..b20d2267 100644 --- a/components/AppHeader.vue +++ b/components/AppHeader.vue @@ -152,6 +152,13 @@ > + @@ -179,6 +186,8 @@ export default class AppHeader extends Vue { @bookApiModule.Action('clearSession') clearSession!: () => void isLoading = false + errorMessage: string | null = null + shouldShowError = false // eslint-disable-next-line class-methods-use-this get isTestnet() { @@ -218,7 +227,9 @@ export default class AppHeader extends Vue { method, }) await this.initWallet(connection) - if (!this.currentAddress || !this.signer) return + if (!this.currentAddress || !this.signer) { + throw new Error('FAILED_TO_CONNECT_WALLET') + } const signature = await this.signMessageMemo('authorize', [ 'profile', 'read:nftbook', @@ -226,7 +237,9 @@ export default class AppHeader extends Vue { 'read:nftcollection', 'write:nftcollection', ]) - if (!signature) { return } + if (!signature) { + throw new Error('SIGNING_REJECTED') + } await this.authenticate({ inputWallet: this.currentAddress, signature }) } } catch (error) { @@ -234,6 +247,8 @@ export default class AppHeader extends Vue { this.clearSession() // eslint-disable-next-line no-console console.error('handleConnectWalletButtonClick error', error) + this.shouldShowError = true + this.errorMessage = error as string } finally { this.isLoading = false diff --git a/layouts/wallet.vue b/layouts/wallet.vue index 8773e5c4..1f5f6099 100644 --- a/layouts/wallet.vue +++ b/layouts/wallet.vue @@ -15,6 +15,13 @@