Skip to content

Commit

Permalink
Merge pull request ChatGPTNextWeb#5719 from ConnectAI-E/hotfix/status…
Browse files Browse the repository at this point in the history
…_text_error

hotfix for statusText is non ISO-8859-1 ChatGPTNextWeb#5717
  • Loading branch information
lloydzhou authored Oct 25, 2024
2 parents 1110a08 + 90ced92 commit 8299484
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/utils/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ export function fetch(url: string, options?: RequestInit): Promise<any> {
})
.catch((e) => {
console.error("stream error", e);
throw e;
// throw e;
return new Response("", { status: 599 });
});
}
return window.fetch(url, options);
Expand Down
15 changes: 13 additions & 2 deletions src-tauri/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,22 @@ pub async fn stream_fetch(
}
}
Err(err) => {
println!("Error response: {:?}", err.source().expect("REASON").to_string());
let error: String = err.source()
.map(|e| e.to_string())
.unwrap_or_else(|| "Unknown error occurred".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(),
}
}
Expand Down

0 comments on commit 8299484

Please sign in to comment.