1use http::Uri;
3use thiserror::Error;
4
5#[allow(deprecated)] pub use kube_core::ErrorResponse;
6pub use kube_core::Status;
7
8#[cfg_attr(docsrs, doc(cfg(any(feature = "config", feature = "client"))))]
10#[derive(Error, Debug)]
11pub enum Error {
12 #[error("ApiError: {0} ({0:?})")]
19 Api(#[source] Box<Status>),
20
21 #[cfg(feature = "client")]
23 #[error("HyperError: {0}")]
24 HyperError(#[source] hyper::Error),
25 #[cfg(feature = "client")]
27 #[error("ServiceError: {0}")]
28 Service(#[source] tower::BoxError),
29
30 #[error("configured proxy {proxy_url:?} uses an unsupported protocol")]
32 ProxyProtocolUnsupported {
33 proxy_url: Uri,
35 },
36 #[error("configured proxy {proxy_url:?} requires the disabled feature {protocol_feature:?}")]
38 ProxyProtocolDisabled {
39 proxy_url: Uri,
41 protocol_feature: &'static str,
43 },
44
45 #[error("UTF-8 Error: {0}")]
47 FromUtf8(#[source] std::string::FromUtf8Error),
48
49 #[error("Error finding newline character")]
53 LinesCodecMaxLineLengthExceeded,
54
55 #[error("Error reading events stream: {0}")]
57 ReadEvents(#[source] std::io::Error),
58
59 #[error("HttpError: {0}")]
61 HttpError(#[source] http::Error),
62
63 #[error("Error deserializing response: {0}")]
65 SerdeError(#[source] serde_json::Error),
66
67 #[error("Failed to build request: {0}")]
69 BuildRequest(#[source] kube_core::request::Error),
70
71 #[error("Failed to infer configuration: {0}")]
73 InferConfig(#[source] crate::config::InferConfigError),
74
75 #[error("Error from discovery: {0}")]
77 Discovery(#[source] DiscoveryError),
78
79 #[cfg(feature = "openssl-tls")]
81 #[cfg_attr(docsrs, doc(cfg(feature = "openssl-tls")))]
82 #[error("openssl tls error: {0}")]
83 OpensslTls(#[source] crate::client::OpensslTlsError),
84
85 #[cfg(feature = "rustls-tls")]
87 #[cfg_attr(docsrs, doc(cfg(feature = "rustls-tls")))]
88 #[error("rustls tls error: {0}")]
89 RustlsTls(#[source] crate::client::RustlsTlsError),
90
91 #[error("TLS required but no TLS stack selected")]
93 TlsRequired,
94
95 #[cfg(feature = "ws")]
97 #[cfg_attr(docsrs, doc(cfg(feature = "ws")))]
98 #[error("failed to upgrade to a WebSocket connection: {0}")]
99 UpgradeConnection(#[source] crate::client::UpgradeConnectionError),
100
101 #[cfg(feature = "client")]
103 #[cfg_attr(docsrs, doc(cfg(feature = "client")))]
104 #[error("auth error: {0}")]
105 Auth(#[source] crate::client::AuthError),
106
107 #[cfg(feature = "unstable-client")]
109 #[cfg_attr(docsrs, doc(cfg(feature = "unstable-client")))]
110 #[error("Reference resolve error: {0}")]
111 RefResolve(String),
112
113 #[error("Failed to infer provided configuration: {0}")]
115 InferKubeconfig(#[from] crate::config::KubeconfigError),
116}
117
118#[derive(Error, Debug)]
119pub enum DiscoveryError {
121 #[error("Invalid GroupVersion: {0}")]
123 InvalidGroupVersion(String),
124
125 #[error("Missing Kind: {0}")]
127 MissingKind(String),
128
129 #[error("Missing Api Group: {0}")]
131 MissingApiGroup(String),
132
133 #[error("Missing Resource: {0}")]
135 MissingResource(String),
136
137 #[error("Empty Api Group: {0}")]
139 EmptyApiGroup(String),
140}