From 8d8635a3e6c8051c92e1712277d2e09c0d64cc85 Mon Sep 17 00:00:00 2001 From: Matthew Raymer Date: Mon, 3 Jul 2023 19:44:41 +0800 Subject: [PATCH] Added try...catch and linted --- src/components/AlertMessage.vue | 21 ++++++++++----------- src/views/ContactAmountsView.vue | 23 +++++++++++++++-------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/components/AlertMessage.vue b/src/components/AlertMessage.vue index 9e8666e..f425e66 100644 --- a/src/components/AlertMessage.vue +++ b/src/components/AlertMessage.vue @@ -1,14 +1,14 @@ diff --git a/src/views/ContactAmountsView.vue b/src/views/ContactAmountsView.vue index b05099f..1b1b46f 100644 --- a/src/views/ContactAmountsView.vue +++ b/src/views/ContactAmountsView.vue @@ -150,16 +150,23 @@ export default class ContactsView extends Vue { // 'created' hook runs when the Vue instance is first created async created() { - await db.open(); - const contactDid = this.$route.query.contactDid as string; - this.contact = (await db.contacts.get(contactDid)) || null; + try { + await db.open(); + const contactDid = this.$route.query.contactDid as string; + this.contact = (await db.contacts.get(contactDid)) || null; - const settings = await db.settings.get(MASTER_SETTINGS_KEY); - this.activeDid = settings?.activeDid || ""; - this.apiServer = settings?.apiServer || ""; + const settings = await db.settings.get(MASTER_SETTINGS_KEY); + this.activeDid = settings?.activeDid || ""; + this.apiServer = settings?.apiServer || ""; - if (this.activeDid && this.contact) { - this.loadGives(this.activeDid, this.contact); + if (this.activeDid && this.contact) { + this.loadGives(this.activeDid, this.contact); + } + } catch (err) { + this.alertTitle = "Error"; + this.alertMessage = + err.userMessage || + "There was an error retrieving the latest sweet, sweet action."; } }