Files
tuliprox/backend/src/api/model/stream_error.rs
T
2025-06-19 12:45:55 +02:00

33 lines
1.0 KiB
Rust

use tokio_stream::wrappers::errors::BroadcastStreamRecvError;
#[derive(Debug, Clone)]
pub enum StreamError {
Reqwest(String),
// StdIo(std::io::Error),
// ReceiverClosed,
ReceiverError(BroadcastStreamRecvError),
LockError(String)
}
impl StreamError {
// pub(crate) fn std_io(msg: String) -> Self {
// StreamError::StdIo(std::io::Error::new(std::io::ErrorKind::Other, msg))
// }
pub fn reqwest(err: &reqwest::Error) -> Self {
Self::Reqwest(err.to_string())
}
}
impl std::error::Error for StreamError {}
impl std::fmt::Display for StreamError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
StreamError::Reqwest(e) => write!(f, "Reqwest error: {e}"),
// StreamError::StdIo(e) => write!(f, "IO error: {e}"),
// StreamError::ReceiverClosed => write!(f, "Receiver closed"),
StreamError::ReceiverError(e) => write!(f, "Receiver error {e}"),
StreamError::LockError(e) => write!(f, "{e}")
}
}
}