CzRger 19 tuntia sitten
vanhempi
commit
d7e932a86a
1 muutettua tiedostoa jossa 4 lisäystä ja 2 poistoa
  1. 4 2
      src/views/chat/chat.ts

+ 4 - 2
src/views/chat/chat.ts

@@ -26,7 +26,10 @@ const handleStream = ({
   onEnd,
   onError,
 }) => {
-  if (!response.ok) throw new Error('Network response was not ok')
+  if (!response.ok) {
+    onError?.(`${response.status}:${response.statusText}`, response)
+    throw new Error('Network response was not ok')
+  }
 
   const reader = response.body?.getReader()
   const decoder = new TextDecoder('utf-8')
@@ -67,7 +70,6 @@ const handleStream = ({
               })
               onError?.(bufferObj.message, bufferObj)
             } else {
-              // onError?.(bufferObj.message, bufferObj)
             }
           }
         })