use thiserror::Error; #[derive(Debug, Error)] pub enum ChatLayerError { #[error("{0}")] Storage(#[from] storagelayer::ChatStorageError), #[error("{0}")] Queue(#[from] queue::QueueError), #[error("{0}")] Redis(#[from] cache::redis::RedisError), #[error("{0}")] Jwt(#[from] jwt::JwtError), #[error("{0}")] Blob(#[from] storage::StorageError), #[error("{0}")] Serde(#[from] serde_json::Error), #[error("invalid input: {0}")] InvalidInput(String), #[error("permission denied: {0}")] PermissionDenied(String), #[error("conflict: {0}")] Conflict(String), #[error("not found: {0}")] NotFound(String), #[error("internal error: {0}")] Internal(String), } pub type ChatLayerResult = Result; impl ChatLayerError { pub fn invalid(msg: impl Into) -> Self { Self::InvalidInput(msg.into()) } pub fn not_found(msg: impl Into) -> Self { Self::NotFound(msg.into()) } pub fn conflict(msg: impl Into) -> Self { Self::Conflict(msg.into()) } }