-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.rs
93 lines (77 loc) · 1.91 KB
/
error.rs
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
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
pub enum Error {
// Process management
ProcessAlreadyRunning,
ProcessNotRunning,
ProcessPidError,
ProcessPipeError,
ProcessSignalError(nix::Error),
// Mods
ModNotFound {
mod_name: String,
mod_version: String,
},
// RCON
RconEmptyCommand,
RconNotConnected,
// SaveHeader
HeaderNotFound,
// Generic
Aggregate(Vec<Error>),
// Generic wrappers around external error types
FactorioDatFileSerde(factorio_file_parser::Error),
Io(std::io::Error),
Json(serde_json::error::Error),
Rcon(rcon::Error),
Reqwest(reqwest::Error),
TomlDe(toml::de::Error),
TomlSer(toml::ser::Error),
Zip(async_zip::error::ZipError),
}
impl std::error::Error for Error {}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self)
}
}
impl From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Self {
Error::Io(e)
}
}
impl From<serde_json::error::Error> for Error {
fn from(e: serde_json::error::Error) -> Self {
Error::Json(e)
}
}
impl From<factorio_file_parser::Error> for Error {
fn from(e: factorio_file_parser::Error) -> Self {
Error::FactorioDatFileSerde(e)
}
}
impl From<rcon::Error> for Error {
fn from(e: rcon::Error) -> Self {
Error::Rcon(e)
}
}
impl From<reqwest::Error> for Error {
fn from(e: reqwest::Error) -> Self {
Error::Reqwest(e)
}
}
impl From<toml::de::Error> for Error {
fn from(e: toml::de::Error) -> Self {
Error::TomlDe(e)
}
}
impl From<toml::ser::Error> for Error {
fn from(e: toml::ser::Error) -> Self {
Error::TomlSer(e)
}
}
impl From<async_zip::error::ZipError> for Error {
fn from(e: async_zip::error::ZipError) -> Self {
Error::Zip(e)
}
}