refactor: improve error mesasge for invalid eventsource content-type (#405)

pull/407/head
sigoden 2 months ago committed by GitHub
parent a3f63a5e04
commit 9f19539c2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -122,6 +122,10 @@ async fn send_message_streaming(builder: RequestBuilder, handler: &mut ReplyHand
check_error(&data)?;
bail!("Invalid status code: {code}");
}
EventSourceError::InvalidContentType(_, res) => {
let text = res.text().await?;
bail!("The endpoint is invalid as the response content-type is not 'text/event-stream', {text}");
}
_ => {
bail!("{}", err);
}

@ -117,6 +117,10 @@ pub async fn openai_send_message_streaming(
}
}
EventSourceError::StreamEnded => {}
EventSourceError::InvalidContentType(_, res) => {
let text = res.text().await?;
bail!("The endpoint is invalid as the response content-type is not 'text/event-stream', {text}");
}
_ => {
bail!("{}", err);
}

Loading…
Cancel
Save