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