Skip to main content

testcontainers_build/
error.rs

1/// Report source and image operation failures.
2/// Command errors include the tool output.
3#[derive(Debug, thiserror::Error)]
4pub enum Error {
5    /// The source or build input is invalid.
6    /// Read the message for the rejected value.
7    #[error("{0}")]
8    InvalidInput(String),
9    /// A file or process operation failed.
10    /// Read the underlying input/output error.
11    #[error(transparent)]
12    Io(#[from] std::io::Error),
13    /// An external tool returned a failure status.
14    /// Read its output for the cause.
15    #[error("{program} failed ({code:?}): {output}")]
16    Command {
17        /// Identify the tool that failed.
18        /// This value contains its file name.
19        program: String,
20        /// Get the process exit code.
21        /// None means that the process ended without an exit code.
22        code: Option<i32>,
23        /// Get the tool output.
24        /// This text can contain source details.
25        output: String,
26    },
27    /// The operation exceeded its timeout.
28    /// The timeout includes source resolution.
29    #[error("source resolution or image build timed out")]
30    Timeout,
31}
32
33/// Return a value or a library error.
34/// Use the error to inspect operation failures.
35pub type Result<T> = std::result::Result<T, Error>;