use std::io; use crate::rpcgit::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 = Result; impl SyncError { #[must_use] pub fn is_locked(&self) -> bool { matches!(self, SyncError::Locked) } }