1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
use log::{debug, error, info, trace, warn};
#[cfg(feature = "s3")]
use s3::creds::error::CredentialsError;
use std::ffi::OsString;
use std::fmt::Debug;
use std::io;
use std::path::PathBuf;
use thiserror::Error as ThisError;
use crate::StorageIdentifier;
#[derive(ThisError, Debug)]
pub enum Error {
#[error("Sorry. {0} is not implemented yet")]
Todo(&'static str),
#[error("General Xvc Remote Error: {source}")]
AnyhowError {
#[from]
source: anyhow::Error,
},
#[error("Xvc ECS Error: {source}")]
EcsError {
#[from]
source: xvc_ecs::error::Error,
},
#[error("Xvc Core Error: {source}")]
CoreError {
#[from]
source: xvc_core::error::Error,
},
#[error("Xvc Config Error: {source}")]
ConfigError {
#[from]
source: xvc_config::error::Error,
},
#[error("Walker Error: {source}")]
WalkerError {
#[from]
source: xvc_walker::error::Error,
},
#[error("I/O Error: {source}")]
IoError {
#[from]
source: io::Error,
},
#[error("Crossbeam Send Error for Type: {t:?} {cause:?}")]
CrossbeamSendError { t: String, cause: String },
#[error("Uuid Error: {source:?}")]
UuidError {
#[from]
source: uuid::Error,
},
#[error("No Guid found for Xvc Repository")]
NoRepositoryGuidFound,
#[error("Cannot find remote with identifier: {identifier}")]
CannotFindRemoteWithIdentifier { identifier: StorageIdentifier },
#[error("Process Exec Error: {source}")]
ProcessExecError {
#[from]
source: subprocess::PopenError,
},
#[cfg(any(feature = "s3", feature = "minio"))]
#[error("Cloud Credentials Error: {source}")]
CloudCredentialsError {
#[from]
source: s3::creds::error::CredentialsError,
},
#[cfg(any(feature = "s3", feature = "minio"))]
#[error("S3 Error: {source}")]
S3Error {
#[from]
source: s3::error::S3Error,
},
}
impl<T> From<crossbeam_channel::SendError<T>> for Error
where
T: Debug,
{
fn from(e: crossbeam_channel::SendError<T>) -> Self {
Error::CrossbeamSendError {
t: format!("{:#?}", e.0),
cause: e.to_string(),
}
}
}
impl Error {
pub fn debug(self) -> Self {
debug!("{}", self);
self
}
pub fn trace(self) -> Self {
trace!("{}", self);
self
}
pub fn warn(self) -> Self {
warn!("{}", self);
self
}
pub fn error(self) -> Self {
error!("{}", self);
self
}
pub fn info(self) -> Self {
info!("{}", self);
self
}
pub fn panic(self) -> Self {
panic!("{}", self);
}
}
pub type Result<T> = std::result::Result<T, Error>;