Skip to content
Clone
194c44c
47 lines 960 B Rust
use std::io;
use gitbaby::error::BabyError;
use redis::RedisError;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum SyncError {
#[error("repository sync lock is held by another worker")]
Locked,
#[error("database error: {0}")]
Db(#[from] sea_orm::DbErr),
#[error("redis error: {0}")]
Redis(#[from] RedisError),
#[error("git error: {0}")]
Git(#[from] BabyError),
#[error("i/o error: {0}")]
Io(#[from] io::Error),
#[error("operation timed out: {0}")]
Timeout(&'static str),
#[error("repository not found: {0}")]
NotFound(String),
#[error("invalid sync task: {0}")]
InvalidTask(String),
#[error("invalid license: {0}")]
InvalidLicense(String),
#[error("internal error: {0}")]
Internal(String),
}
pub type SyncResult<T> = Result<T, SyncError>;
impl SyncError {
#[must_use]
pub fn is_locked(&self) -> bool {
matches!(self, SyncError::Locked)
}
}