goofy.js: Hide loading screen even when something goes wrong.

Hide the loading screen even when some initialize went wrong, so the
exception is shown in the console window and it's easier to see what
went wrong.

BUG=b:64963909
TEST=make test

Change-Id: I8c5f7a0695170e43bafc1caafb4c7ebb49832bc8
Reviewed-on: https://chromium-review.googlesource.com/942765
Commit-Ready: Pi-Hsun Shih <pihsun@chromium.org>
Tested-by: Pi-Hsun Shih <pihsun@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
diff --git a/py/goofy/js/goofy.js b/py/goofy/js/goofy.js
index 08da7ce..05f6d58 100644
--- a/py/goofy/js/goofy.js
+++ b/py/goofy/js/goofy.js
@@ -1102,12 +1102,18 @@
    * Starts the UI.
    */
   async init() {
-    this.initUIComponents();
-    await this.initLocaleSelector();
-    const testList = await this.sendRpc('GetTestList');
-    await this.setTestList(testList);
-    this.initWebSocket();
-    document.getElementById('goofy-div-wait').style.display = 'none';
+    try {
+      this.initUIComponents();
+      await this.initLocaleSelector();
+      const testList = await this.sendRpc('GetTestList');
+      await this.setTestList(testList);
+      this.initWebSocket();
+    } finally {
+      // Hide the "Loading..." screen even if there's error when initialize
+      // previous items, so the exception is shown on screen and easier to
+      // know what went wrong.
+      document.getElementById('goofy-div-wait').style.display = 'none';
+    }
 
     await Promise.all([
       (async () => {