Skip to content
Clone
e034b46
53 lines 1.1 KB Rust
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<T> = Result<T, ChatLayerError>;
impl ChatLayerError {
pub fn invalid(msg: impl Into<String>) -> Self {
Self::InvalidInput(msg.into())
}
pub fn not_found(msg: impl Into<String>) -> Self {
Self::NotFound(msg.into())
}
pub fn conflict(msg: impl Into<String>) -> Self {
Self::Conflict(msg.into())
}
}