[object Object]

← back to Exo

removing error separtation so I can put in different PR

fb32a851b1ae050e61b4a99ae10bd3a11e82fc50 · 2024-11-13 15:19:36 -0800 · cadenmackenzie

Files touched

Diff

commit fb32a851b1ae050e61b4a99ae10bd3a11e82fc50
Author: cadenmackenzie <cadenmackenzie@gmail.com>
Date:   Wed Nov 13 15:19:36 2024 -0800

    removing error separtation so I can put in different PR
---
 exo/tinychat/index.js | 70 ++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 47 insertions(+), 23 deletions(-)

diff --git a/exo/tinychat/index.js b/exo/tinychat/index.js
index 9c64853f..c8673598 100644
--- a/exo/tinychat/index.js
+++ b/exo/tinychat/index.js
@@ -13,7 +13,7 @@ document.addEventListener("alpine:init", () => {
     home: 0,
     generating: false,
     endpoint: `${window.location.origin}/v1`,
-    
+
     // Initialize error message structure
     errorMessage: null,
     errorExpanded: false,
@@ -157,7 +157,29 @@ document.addEventListener("alpine:init", () => {
         this.processMessage(value);
       } catch (error) {
         console.error('error', error);
-        this.setError(error);
+        const errorDetails = {
+            message: error.message || 'Unknown error',
+            stack: error.stack,
+            name: error.name || 'Error'
+        };
+
+        this.errorMessage = {
+            basic: `${errorDetails.name}: ${errorDetails.message}`,
+            stack: errorDetails.stack
+        };
+
+        // Clear any existing timeout
+        if (this.errorTimeout) {
+            clearTimeout(this.errorTimeout);
+        }
+
+        // Only set the timeout if the error details aren't expanded
+        if (!this.errorExpanded) {
+            this.errorTimeout = setTimeout(() => {
+                this.errorMessage = null;
+                this.errorExpanded = false;
+            }, 30 * 1000);
+        }
         this.generating = false;
       }
     },
@@ -275,7 +297,29 @@ document.addEventListener("alpine:init", () => {
         }
       } catch (error) {
         console.error('error', error);
-        this.setError(error);
+        const errorDetails = {
+            message: error.message || 'Unknown error',
+            stack: error.stack,
+            name: error.name || 'Error'
+        };
+
+        this.errorMessage = {
+            basic: `${errorDetails.name}: ${errorDetails.message}`,
+            stack: errorDetails.stack
+        };
+
+        // Clear any existing timeout
+        if (this.errorTimeout) {
+            clearTimeout(this.errorTimeout);
+        }
+
+        // Only set the timeout if the error details aren't expanded
+        if (!this.errorExpanded) {
+            this.errorTimeout = setTimeout(() => {
+                this.errorMessage = null;
+                this.errorExpanded = false;
+            }, 30 * 1000);
+        }
       } finally {
         this.generating = false;
       }
@@ -411,26 +455,6 @@ document.addEventListener("alpine:init", () => {
         this.fetchDownloadProgress();
       }, 1000); // Poll every second
     },
-
-    // Add a helper method to set errors consistently
-    setError(error) {
-      this.errorMessage = {
-        basic: error.message || "An unknown error occurred",
-        stack: error.stack || ""
-      };
-      this.errorExpanded = false;
-      
-      if (this.errorTimeout) {
-        clearTimeout(this.errorTimeout);
-      }
-
-      if (!this.errorExpanded) {
-        this.errorTimeout = setTimeout(() => {
-          this.errorMessage = null;
-          this.errorExpanded = false;
-        }, 30 * 1000);
-      }
-    },
   }));
 });
 

← 7d7bdd83 removing uneccesary console logs and fixing order of variabl  ·  back to Exo  ·  adding back in set error message 59f5b6d8 →