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
use std::cmp;
use std::fmt::{Display, Formatter, Result};
#[derive(Fail, Copy, Clone, Debug)]
#[fail(display = "could not find DOCKER_CERT_PATH")]
#[allow(missing_docs)]
pub struct NoCertPathError {}
#[derive(Fail, Debug)]
#[fail(display = "API responded with a 404 not found: {}", message)]
#[allow(missing_docs)]
pub struct DockerResponseNotFoundError {
pub message: String,
}
#[derive(Fail, Debug)]
#[fail(
display = "Docker responded with status code {}: {}",
status_code, message
)]
#[allow(missing_docs)]
pub struct DockerResponseServerError {
pub status_code: u16,
pub message: String,
}
#[derive(Fail, Debug)]
#[fail(display = "API queried with a bad parameter: {}", message)]
#[allow(missing_docs)]
pub struct DockerResponseBadParameterError {
pub message: String,
}
#[derive(Fail, Debug)]
#[fail(display = "API responded with a 409 conflict: {}", message)]
#[allow(missing_docs)]
pub struct DockerResponseConflictError {
pub message: String,
}
#[derive(Fail, Debug)]
#[fail(
display = "API responded with a 304, resource was not modified: {}",
message
)]
#[allow(missing_docs)]
pub struct DockerResponseNotModifiedError {
pub message: String,
}
#[derive(Fail, Debug)]
#[allow(missing_docs)]
pub struct JsonDataError {
pub message: String,
pub contents: String,
pub column: usize,
}
impl Display for JsonDataError {
fn fmt(&self, f: &mut Formatter) -> Result {
let backtrack_len: usize = 24;
let peek_len: usize = 32;
let description = "Failed to deserialize near ...";
let from_start_length = self.column.checked_sub(backtrack_len).unwrap_or(0);
write!(
f,
"{}{}...\n{}",
description,
&self.contents
[from_start_length..cmp::min(self.contents.len(), self.column + peek_len)],
self.message
)
}
}
#[derive(Fail, Debug)]
#[fail(display = "Failed to parse API version: {}", api_version)]
#[allow(missing_docs)]
pub struct APIVersionParseError {
pub api_version: String,
}