Define specific error for event stream ended
This commit is contained in:
@@ -68,6 +68,9 @@ impl<T: TokenProvider + Clone> GeminiClient<T> {
|
|||||||
let mapped = event_source.filter_map(|event| {
|
let mapped = event_source.filter_map(|event| {
|
||||||
let event = match event {
|
let event = match event {
|
||||||
Ok(event) => event,
|
Ok(event) => event,
|
||||||
|
Err(reqwest_eventsource::Error::StreamEnded) => {
|
||||||
|
return Some(Err(Error::EventSourceClosedError))
|
||||||
|
}
|
||||||
Err(e) => return Some(Err(e.into())),
|
Err(e) => return Some(Err(e.into())),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ pub enum Error {
|
|||||||
NoCandidatesError,
|
NoCandidatesError,
|
||||||
CannotCloneRequestError(CannotCloneRequestError),
|
CannotCloneRequestError(CannotCloneRequestError),
|
||||||
EventSourceError(reqwest_eventsource::Error),
|
EventSourceError(reqwest_eventsource::Error),
|
||||||
|
EventSourceClosedError,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for Error {
|
impl Display for Error {
|
||||||
@@ -37,6 +38,9 @@ impl Display for Error {
|
|||||||
Error::EventSourceError(e) => {
|
Error::EventSourceError(e) => {
|
||||||
write!(f, "EventSourrce Error: {}", e)
|
write!(f, "EventSourrce Error: {}", e)
|
||||||
}
|
}
|
||||||
|
Error::EventSourceClosedError => {
|
||||||
|
write!(f, "EventSource closed error")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user