use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Error)]
pub enum Error {
#[error("storage error: {0}")]
Storage(String),
#[error("transport error: {0}")]
Transport(String),
#[error("mls protocol error: {0}")]
Mls(String),
#[error("identity error: {0}")]
Identity(String),
#[error("unknown conversation: {0}")]
UnknownConversation(String),
#[error("unknown device: {0}")]
UnknownDevice(String),
#[error("epoch occupied: caller must rebase on the new epoch and retry")]
EpochOccupied,
#[error("codec error: {0}")]
Codec(String),
#[error("invalid input: {0}")]
Invalid(String),
#[error("not initialised")]
NotInitialised,
}
impl Error {
pub(crate) fn mls<E: std::fmt::Display>(e: E) -> Self {
Error::Mls(e.to_string())
}
pub(crate) fn codec<E: std::fmt::Display>(e: E) -> Self {
Error::Codec(e.to_string())
}
}