From 9329646a1d02939fc6e4bc8c1a53623c7115f0d6 Mon Sep 17 00:00:00 2001 From: Joe Schnetzler Date: Tue, 12 Sep 2023 17:18:34 +0000 Subject: [PATCH] Try catches --- packages/ui/src/routes/+page.svelte | 33 +++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/packages/ui/src/routes/+page.svelte b/packages/ui/src/routes/+page.svelte index 43fb72f..4de7c89 100644 --- a/packages/ui/src/routes/+page.svelte +++ b/packages/ui/src/routes/+page.svelte @@ -14,23 +14,38 @@ let loading = false; $: if (isMetaMaskInstalledValue && isSnapInitValue && isSnapInstalledValue) { + $state.connected = true; goto("/balances"); } const initializeData = async () => { - loading = true; - isMetaMaskInstalledValue = isMetaMaskInstalled() ?? false; - isSnapInstalledValue = await isSnapInstalled() ?? false; - loading = false; + try { + loading = true; + isMetaMaskInstalledValue = isMetaMaskInstalled() ?? false; + isSnapInstalledValue = await isSnapInstalled() ?? false; + loading = false; + } catch (err: any) { + loading = false; + $state.alertText = `${err.message}` + $state.alertType = "danger" + $state.showAlert = true + } }; const runInstallSnap = async () => { - loading = true; - await installSnap(); - isSnapInstalledValue = true; - isSnapInitValue = false; - loading = false; + try { + loading = true; + await installSnap(); + isSnapInstalledValue = true; + isSnapInitValue = false; + loading = false; + } catch (err: any) { + loading = false; + $state.alertText = `${err.message}` + $state.alertType = "danger" + $state.showAlert = true + } }; const initializeSnap = async () => {