Skip to main content

fluidattacks_core_git/
errors.rs

1use 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    /// git ran and refused, as it does for a missing repository or revision.
18    #[error("git {command} exited with {status}: {stderr}")]
19    Refused {
20        command: &'static str,
21        status: ExitStatus,
22        stderr: String,
23    },
24    /// No process can receive a NUL, so std turns the call down before it starts.
25    #[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/// How extracting a gzipped tar failed.
35#[derive(Debug, thiserror::Error)]
36pub enum ExtractError {
37    /// The archive is not gzip, its tar or deflate data is broken, or its
38    /// checksum does not match.
39    #[error("corrupt archive: {0}")]
40    Corrupt(#[source] io::Error),
41    /// The gzip stream ends before its trailer.
42    #[error("truncated archive: {0}")]
43    Truncated(#[source] io::Error),
44    #[error("extracting the archive: {0}")]
45    Io(#[source] io::Error),
46}