pub type Result<T, E = RadionError> = std::result::Result<T, E>;
#[derive(Debug, Clone, thiserror::Error)]
#[non_exhaustive]
pub enum RadionError {
#[error("{0}")]
Connection(String),
#[error("{message}")]
Server {
message: String,
code: Option<String>,
channel: Option<String>,
id: Option<String>,
},
#[error("transport error: {0}")]
Transport(String),
#[error("decompression error: {0}")]
Decompression(String),
}
impl RadionError {
pub(crate) fn connection(message: impl Into<String>) -> Self {
Self::Connection(message.into())
}
#[cfg(feature = "realtime")]
pub(crate) fn transport(source: impl std::fmt::Display) -> Self {
Self::Transport(source.to_string())
}
#[cfg(feature = "compression")]
pub(crate) fn decompression(source: impl std::fmt::Display) -> Self {
Self::Decompression(source.to_string())
}
}