bollard_next/
errors.rs

1//! Errors for this module.
2
3#[cfg(feature = "ssl_providerless")]
4use std::path::PathBuf;
5
6/// Generic Docker errors
7#[derive(Debug, thiserror::Error)]
8pub enum Error {
9    /// Error emitted during client instantiation when the `DOCKER_CERT_PATH` environment variable
10    /// is invalid.
11    #[cfg(feature = "ssl_providerless")]
12    #[error("Could not find home directory")]
13    NoHomePathError,
14    /// Generic error when reading a certificate from the filesystem
15    #[cfg(feature = "ssl_providerless")]
16    #[error("Cannot open/read certificate with path: {path}")]
17    CertPathError {
18        /// Path for the failing certificate file
19        path: PathBuf,
20    },
21    /// Error emitted when multiple keys are found in a certificate file
22    #[cfg(feature = "ssl_providerless")]
23    #[error("Found multiple keys ({count}), expected one: {path}")]
24    CertMultipleKeys {
25        /// Number of keys found in the certificate file
26        count: usize,
27        /// Path for the failing certificate file
28        path: PathBuf,
29    },
30    /// Parse error for RSA encrypted keys
31    #[cfg(feature = "ssl_providerless")]
32    #[error("Could not parse key: {path}")]
33    CertParseError {
34        /// Path for the failing certificate file
35        path: PathBuf,
36    },
37    /// Error emitted when the client is unable to parse a native pki cert for SSL
38    #[cfg(feature = "ssl_providerless")]
39    #[error("Could not parse a pki native cert")]
40    NoNativeCertsError {
41        /// The original error emitted.
42        #[from]
43        err: rustls::Error,
44    },
45    /// Error emitted when the client is unable to load native certs for SSL
46    #[cfg(feature = "ssl_providerless")]
47    #[error("Could not load native certs")]
48    LoadNativeCertsErrors {
49        /// The original errors emitted.
50        errors: Vec<rustls_native_certs::Error>,
51    },
52    /// Generic error emitted by the docker server.
53    #[error("Docker responded with status code {status_code}: {message}")]
54    DockerResponseServerError {
55        /// Status code returned by the docker server.
56        status_code: u16,
57        /// Message returned by the docker server.
58        message: String,
59    },
60    /// Error facilitating debugging failed JSON parsing.
61    #[error("Failed to deserialize JSON: {message}")]
62    JsonDataError {
63        /// Short section of the json close to the error.
64        message: String,
65        /// Entire JSON payload. This field is toggled with the **json_data_content** feature cargo flag.
66        #[cfg(feature = "json_data_content")]
67        contents: String,
68        /// Character sequence at error location.
69        column: usize,
70    },
71    /// Error emitted when the docker is requested to build with buildkit without a session id
72    #[error("Failed to parse API version")]
73    APIVersionParseError {},
74    /// Error emitted when a request times out.
75    #[error("Timeout error")]
76    RequestTimeoutError,
77    /// Error emitted mid-stream as part of a successful docker operation
78    #[error("Docker stream error")]
79    DockerStreamError {
80        /// error string emitted by the Stream
81        error: String,
82    },
83    /// Error emitted as part of a container wait response
84    #[error("Docker container wait error")]
85    DockerContainerWaitError {
86        /// error string returned from container wait call
87        error: String,
88        /// error code returned from container wait call
89        code: i64,
90    },
91    /// Error emitted when a session is not provided to the buildkit engine
92    #[error("Buildkit requires a unique session")]
93    MissingSessionBuildkitError {},
94    /// Error emitted when a session is not provided to the buildkit engine
95    #[error("Buildkit requires a builder version set")]
96    MissingVersionBuildkitError {},
97    /// Error emitted when JSON fails to serialize.
98    #[error(transparent)]
99    JsonSerdeError {
100        /// The original error emitted by serde.
101        #[from]
102        err: serde_json::Error,
103    },
104    /// Error emitted when log output generates an I/O error.
105    #[error(transparent)]
106    StrParseError {
107        /// The original error emitted.
108        #[from]
109        err: std::str::Utf8Error,
110    },
111    /// Error emitted from an I/O error.
112    #[error(transparent)]
113    IOError {
114        /// The original error emitted.
115        #[from]
116        err: std::io::Error,
117    },
118    /// Error emitted from a formatting error.
119    #[error(transparent)]
120    StrFmtError {
121        /// The original error emitted.
122        #[from]
123        err: std::fmt::Error,
124    },
125    /// Error emitted from an HTTP error.
126    #[error(transparent)]
127    HttpClientError {
128        /// The original error emitted.
129        #[from]
130        err: http::Error,
131    },
132    /// Error emitted from an HTTP error.
133    #[error(transparent)]
134    HyperResponseError {
135        /// The original error emitted.
136        #[from]
137        err: hyper::Error,
138    },
139    /// Error emitted when serde fails to urlencod a struct of options
140    #[error("Unable to URLEncode: {}", err)]
141    URLEncodedError {
142        /// The original error emitted.
143        #[from]
144        err: serde_urlencoded::ser::Error,
145    },
146    /// Error encountered when parsing a URL
147    #[error("Unable to parse URL: {}", err)]
148    URLParseError {
149        /// The original error emitted.
150        #[from]
151        err: url::ParseError,
152    },
153    /// Error emitted when encoding a URI
154    #[error("Unable to parse URI: {}", err)]
155    InvalidURIError {
156        /// The original error emitted.
157        #[from]
158        err: http::uri::InvalidUri,
159    },
160    /// Error emitted when encoding a URIParts
161    #[error("Unable to parse URIParts: {}", err)]
162    InvalidURIPartsError {
163        /// The original error emitted.
164        #[from]
165        err: http::uri::InvalidUriParts,
166    },
167    /// Error that is never emitted
168    #[cfg(feature = "http")]
169    #[error("Error in the hyper legacy client: {}", err)]
170    HyperLegacyError {
171        /// The original error emitted.
172        #[from]
173        err: hyper_util::client::legacy::Error,
174    },
175    /// Error emitted when connecting to a URI with an unsupported scheme
176    #[error("URI scheme is not supported: {uri}")]
177    UnsupportedURISchemeError {
178        /// The URI that was attempted to be connected to
179        uri: String,
180    },
181    /// Error emitted when the Docker socket file is not found at the expected location.
182    #[error("Socket not found: {0}")]
183    SocketNotFoundError(String),
184}