1use crate::git::GitError;
2use crate::provider::MirrorError;
3use thiserror::Error;
4
5#[derive(Error, Debug)]
6pub enum GitMirrorError {
7 #[error("Generic Mirror error: {0}")]
8 GenericError(String),
9 #[error("Git command execution failed: {0}")]
10 GitError(#[from] Box<GitError>),
11 #[error("Mirror extraction failed: {0}")]
12 MirrorError(#[from] Box<MirrorError>),
13 #[error("{0} sync tasks failed")]
14 SyncError(usize),
15}
16
17impl From<GitMirrorError> for i32 {
18 fn from(mirror: GitMirrorError) -> i32 {
19 match mirror {
20 GitMirrorError::SyncError(_) => 1,
21 GitMirrorError::GenericError(_) => 2,
22 GitMirrorError::GitError(_) => 3,
23 GitMirrorError::MirrorError(_) => 4,
24 }
25 }
26}
27
28pub type Result<T> = core::result::Result<T, GitMirrorError>;