use std::sync::PoisonError;
use async_broadcast::SendError;
#[derive(thiserror::Error, Debug)]
#[allow(missing_docs)]
#[non_exhaustive]
pub enum Error
{
#[error("RecvError in streams communication, most likely end of stream: {0}.")]
RecvError(#[from] async_broadcast::RecvError),
#[error("SendError in streams communication, most likely end of stream: {0}.")]
SendError(String),
#[cfg(feature = "http")]
#[error("When retrieving from HTTP: {0}.")]
HttpError(#[from] isahc::Error),
#[error("IO Error: {0}.")]
IOError(#[from] std::io::Error),
#[cfg(feature = "html")]
#[error("When retrieving from html2text: {0}.")]
Html2TextError(#[from] html2text::Error),
#[error("Serialization error: {0}")]
JsonSerializationError(#[from] serde_json::Error),
#[error("Deserialization error: {0}")]
DeserializationError(String),
#[error("Poison (Mutex/RwLock) error: {0}")]
PoisonError(String),
#[error("{0}")]
ValueError(#[from] crate::values::Error),
#[error("{0}")]
LlmError(#[from] crate::llm::Error),
}
impl<T> From<SendError<T>> for Error
{
fn from(value: SendError<T>) -> Self
{
Error::SendError(format!("{:?}", value))
}
}
impl<T> From<PoisonError<T>> for Error
{
fn from(value: PoisonError<T>) -> Self
{
Error::PoisonError(value.to_string())
}
}