alpm_mtree/file/error.rs
1//! Error handling for [ALPM-MTREE] creation.
2//!
3//! [ALPM-MTREE]: https://alpm.archlinux.page/specifications/ALPM-MTREE.5.html
4
5use std::process::ExitStatus;
6
7/// The Error that can occur when creating [ALPM-MTREE] files.
8///
9/// [ALPM-MTREE]: https://alpm.archlinux.page/specifications/ALPM-MTREE.5.html
10#[derive(Debug, thiserror::Error)]
11pub enum Error {
12 /// An alpm-common error.
13 #[error("ALPM common error:\n{0}")]
14 AlpmCommon(#[from] alpm_common::Error),
15
16 /// Unable to attach to stdin of a command.
17 #[error("Unable to attach to stdin of command {command:?}")]
18 CommandAttachToStdin {
19 /// The command for which attaching to stdin failed.
20 command: String,
21 },
22
23 /// A command could not be started in the background.
24 #[error("The command {command:?} could not be started in the background:\n{source}")]
25 CommandBackground {
26 /// The command that could not be started in the background.
27 command: String,
28 /// The source error.
29 source: std::io::Error,
30 },
31
32 /// A command could not be executed.
33 #[error("The command {command:?} could not be executed:\n{source}")]
34 CommandExec {
35 /// The command that could not be executed.
36 command: String,
37 /// The source error.
38 source: std::io::Error,
39 },
40
41 /// A command exited unsuccessfully.
42 #[error(
43 "The command {command:?} exited with non-zero status code {exit_status:?}:\nstderr:\n{stderr}"
44 )]
45 CommandNonZero {
46 /// The command that exited with a non-zero exit code.
47 command: String,
48 /// The exit status of `command`.
49 exit_status: ExitStatus,
50 /// The stderr of `command`.
51 stderr: String,
52 },
53
54 /// A command exited unsuccessfully.
55 #[error("The command {command:?} could not be found:\n{source}")]
56 CommandNotFound {
57 /// The command that exited with a non-zero exit code.
58 command: &'static str,
59 /// The source error.
60 source: which::Error,
61 },
62
63 /// Unable to write to stdin of a command.
64 #[error("Unable to write to stdin of command {command:?}")]
65 CommandWriteToStdin {
66 /// The command for which writing to stdin failed.
67 command: String,
68 /// The source error.
69 source: std::io::Error,
70 },
71}