From eb3880b4351422d262b5273ee67e2fc0aa1dab9b Mon Sep 17 00:00:00 2001
From: Lim Chee Aun <cheeaun@gmail.com>
Date: Tue, 27 Dec 2022 01:07:33 +0800
Subject: [PATCH] Handle errors here

---
 src/components/compose.jsx | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/components/compose.jsx b/src/components/compose.jsx
index 08bb5b58..06b277f2 100644
--- a/src/components/compose.jsx
+++ b/src/components/compose.jsx
@@ -58,13 +58,19 @@ function Compose({
   ).info;
 
   const configuration = useMemo(() => {
-    const instances = store.local.getJSON('instances');
-    const currentInstance = accounts.find(
-      (a) => a.info.id === currentAccount,
-    ).instanceURL;
-    const config = instances[currentInstance].configuration;
-    console.log(config);
-    return config;
+    try {
+      const instances = store.local.getJSON('instances');
+      const currentInstance = accounts.find(
+        (a) => a.info.id === currentAccount,
+      ).instanceURL;
+      const config = instances[currentInstance].configuration;
+      console.log(config);
+      return config;
+    } catch (e) {
+      alert('Failed to load instance configuration. Please try again.');
+      console.error(e);
+      return {};
+    }
   }, []);
 
   const {