fluidattacks_core_git/
errors.rs1use std::io;
2use std::process::ExitStatus;
3use std::time::Duration;
4
5#[derive(Debug, thiserror::Error)]
6pub enum GitCallError {
7 #[error("git {command} could not start: {source}")]
8 NotStarted {
9 command: &'static str,
10 source: io::Error,
11 },
12 #[error("git {command} did not finish within {after:?}")]
13 TimedOut {
14 command: &'static str,
15 after: Duration,
16 },
17 #[error("git {command} exited with {status}: {stderr}")]
19 Refused {
20 command: &'static str,
21 status: ExitStatus,
22 stderr: String,
23 },
24 #[error("git {command} got an argument with an embedded null byte")]
26 NullByte { command: &'static str },
27 #[error("git {command} printed something unreadable: {reason}")]
28 Malformed {
29 command: &'static str,
30 reason: String,
31 },
32}
33
34#[derive(Debug, thiserror::Error)]
36pub enum DownloadError {
37 #[error("writing the archive: {0}")]
40 Write(#[source] io::Error),
41 #[error(transparent)]
42 Fetch(#[from] FetchError),
43 #[error(transparent)]
44 Extract(#[from] ExtractError),
45 #[error(transparent)]
47 Reset(#[from] GitCallError),
48 #[error("pruning the working tree: {message}")]
51 Prune { message: String, errno: Option<i32> },
52 #[error("placing the repository: {0}")]
54 Place(#[source] io::Error),
55}
56
57#[derive(Debug, thiserror::Error)]
59pub enum FetchError {
60 #[error("invalid url {url}: {reason}")]
61 InvalidUrl { url: String, reason: String },
62 #[error("not an http url: {0}")]
63 NonHttpUrl(String),
64 #[error("could not connect: {0}")]
66 Connect(#[source] reqwest::Error),
67 #[error("connecting timed out: {0}")]
68 ConnectTimeout(#[source] reqwest::Error),
69 #[error("no response in time: {0}")]
71 Timeout(#[source] reqwest::Error),
72 #[error("the server disconnected: {0}")]
74 Disconnected(#[source] reqwest::Error),
75 #[error("the socket failed: {source}")]
78 Socket {
79 reset: bool,
80 errno: Option<i32>,
81 source: reqwest::Error,
82 },
83 #[error("malformed response: {0}")]
84 Malformed(#[source] reqwest::Error),
85 #[error("the server answered {0}")]
86 Status(reqwest::StatusCode),
87 #[error("the body was cut: {0}")]
89 BodyCut(#[source] reqwest::Error),
90 #[error("the body did not arrive in time: {0}")]
92 BodyTimeout(#[source] reqwest::Error),
93 #[error("the request failed: {0}")]
94 Other(#[source] reqwest::Error),
95}
96
97#[derive(Debug, thiserror::Error)]
99pub enum ExtractError {
100 #[error("corrupt archive: {0}")]
103 Corrupt(#[source] io::Error),
104 #[error("truncated archive: {0}")]
106 Truncated(#[source] io::Error),
107 #[error("the archive holds no repository: {0}")]
109 NoRepository(String),
110 #[error("extracting the archive: {0}")]
111 Io(#[source] io::Error),
112}