docker_client_async/
error.rs

1/*
2 * Copyright 2020 Damian Peckett <damian@pecke.tt>.
3 * Copyright 2013-2018 Docker, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *     https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18//! Docker client errors.
19
20use hyper::http;
21use snafu::Snafu;
22
23/// Docker client errors.
24#[derive(Debug, Snafu)]
25#[snafu(visibility = "pub(crate)")]
26pub enum Error {
27    /// Failed to decode a base64 encoded field.
28    #[snafu(display("base64 decoding error: {}", source))]
29    B64DecodingError { source: base64::DecodeError },
30
31    /// Failed to parse a TLS certificate.
32    #[snafu(display("certificate parse error: {}", source))]
33    CertificateParseError { source: native_tls::Error },
34
35    /// General TLS error.
36    #[snafu(display("crypto error: {}", source))]
37    CryptoError { source: openssl::error::ErrorStack },
38
39    /// General HTTP client error.
40    #[snafu(display("http client error: {}", source))]
41    HttpClientError { source: hyper::Error },
42
43    /// Failed to build HTTP client request.
44    #[snafu(display("http client request builder error: {}", source))]
45    HttpClientRequestBuilderError { source: http::Error },
46
47    /// Bad response to HTTP request.
48    #[snafu(display("http client response error: status = {}", status))]
49    HttpClientResponseError { status: u16 },
50
51    /// HTTP request timed out.
52    #[snafu(display("http client timeout error: {}", source))]
53    HttpClientTimeoutError { source: tokio::time::Elapsed },
54
55    /// Invalid HTTP address.
56    #[snafu(display("http uri error: {}", source))]
57    HttpUriError { source: http::uri::InvalidUri },
58
59    /// General IO errors.
60    #[snafu(display("io error: {}", source))]
61    IoError { source: std::io::Error },
62
63    /// Failed to deserialize json response.
64    #[snafu(display("json deserialization error: {}", source))]
65    JsonDeserializationError { source: serde_json::Error },
66
67    /// Failed to serialize json request.
68    #[snafu(display("json serialization error: {}", source))]
69    JsonSerializationError { source: serde_json::Error },
70
71    /// Unexpected response from Docker api.
72    #[snafu(display("malformed response"))]
73    MalformedResponseError {},
74}