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}