1use http::Uri;
3use thiserror::Error;
4
5pub use kube_core::ErrorResponse;
6
7#[cfg_attr(docsrs, doc(cfg(any(feature = "config", feature = "client"))))]
9#[derive(Error, Debug)]
10pub enum Error {
11 #[error("ApiError: {0} ({0:?})")]
18 Api(#[source] ErrorResponse),
19
20 #[cfg(feature = "client")]
22 #[error("HyperError: {0}")]
23 HyperError(#[source] hyper::Error),
24 #[cfg(feature = "client")]
26 #[error("ServiceError: {0}")]
27 Service(#[source] tower::BoxError),
28
29 #[error("configured proxy {proxy_url:?} uses an unsupported protocol")]
31 ProxyProtocolUnsupported {
32 proxy_url: Uri,
34 },
35 #[error("configured proxy {proxy_url:?} requires the disabled feature {protocol_feature:?}")]
37 ProxyProtocolDisabled {
38 proxy_url: Uri,
40 protocol_feature: &'static str,
42 },
43
44 #[error("UTF-8 Error: {0}")]
46 FromUtf8(#[source] std::string::FromUtf8Error),
47
48 #[error("Error finding newline character")]
52 LinesCodecMaxLineLengthExceeded,
53
54 #[error("Error reading events stream: {0}")]
56 ReadEvents(#[source] std::io::Error),
57
58 #[error("HttpError: {0}")]
60 HttpError(#[source] http::Error),
61
62 #[error("Error deserializing response: {0}")]
64 SerdeError(#[source] serde_json::Error),
65
66 #[error("Failed to build request: {0}")]
68 BuildRequest(#[source] kube_core::request::Error),
69
70 #[error("Failed to infer configuration: {0}")]
72 InferConfig(#[source] crate::config::InferConfigError),
73
74 #[error("Error from discovery: {0}")]
76 Discovery(#[source] DiscoveryError),
77
78 #[cfg(feature = "openssl-tls")]
80 #[cfg_attr(docsrs, doc(cfg(feature = "openssl-tls")))]
81 #[error("openssl tls error: {0}")]
82 OpensslTls(#[source] crate::client::OpensslTlsError),
83
84 #[cfg(feature = "rustls-tls")]
86 #[cfg_attr(docsrs, doc(cfg(feature = "rustls-tls")))]
87 #[error("rustls tls error: {0}")]
88 RustlsTls(#[source] crate::client::RustlsTlsError),
89
90 #[error("TLS required but no TLS stack selected")]
92 TlsRequired,
93
94 #[cfg(feature = "ws")]
96 #[cfg_attr(docsrs, doc(cfg(feature = "ws")))]
97 #[error("failed to upgrade to a WebSocket connection: {0}")]
98 UpgradeConnection(#[source] crate::client::UpgradeConnectionError),
99
100 #[cfg(feature = "client")]
102 #[cfg_attr(docsrs, doc(cfg(feature = "client")))]
103 #[error("auth error: {0}")]
104 Auth(#[source] crate::client::AuthError),
105
106 #[cfg(feature = "unstable-client")]
108 #[cfg_attr(docsrs, doc(cfg(feature = "unstable-client")))]
109 #[error("Reference resolve error: {0}")]
110 RefResolve(String),
111}
112
113#[derive(Error, Debug)]
114pub enum DiscoveryError {
116 #[error("Invalid GroupVersion: {0}")]
118 InvalidGroupVersion(String),
119
120 #[error("Missing Kind: {0}")]
122 MissingKind(String),
123
124 #[error("Missing Api Group: {0}")]
126 MissingApiGroup(String),
127
128 #[error("Missing Resource: {0}")]
130 MissingResource(String),
131
132 #[error("Empty Api Group: {0}")]
134 EmptyApiGroup(String),
135}