소스 검색

hotfix for statusText is non ISO-8859-1 #5717

lloydzhou 1 년 전
부모
커밋
e3ca7e8b44
1개의 변경된 파일11개의 추가작업 그리고 2개의 파일을 삭제
  1. 11 2
      src-tauri/src/stream.rs

+ 11 - 2
src-tauri/src/stream.rs

@@ -119,11 +119,20 @@ pub async fn stream_fetch(
       }
     }
     Err(err) => {
-      println!("Error response: {:?}", err.source().expect("REASON").to_string());
+      let error: String = err.source().expect("REASON").to_string();
+      println!("Error response: {:?}", error);
+      tauri::async_runtime::spawn( async move {
+        if let Err(e) = window.emit(event_name, ChunkPayload{ request_id, chunk: error.into() }) {
+          println!("Failed to emit chunk payload: {:?}", e);
+        }
+        if let Err(e) = window.emit(event_name, EndPayload{ request_id, status: 0 }) {
+          println!("Failed to emit end payload: {:?}", e);
+        }
+      });
       StreamResponse {
         request_id,
         status: 599,
-        status_text: err.source().expect("REASON").to_string(),
+        status_text: "Error".to_string(),
         headers: HashMap::new(),
       }
     }