use http::Uri;
use thiserror::Error;
pub use kube_core::ErrorResponse;
#[cfg_attr(docsrs, doc(cfg(any(feature = "config", feature = "client"))))]
#[derive(Error, Debug)]
pub enum Error {
#[error("ApiError: {0} ({0:?})")]
Api(#[source] ErrorResponse),
#[cfg(feature = "client")]
#[error("HyperError: {0}")]
HyperError(#[source] hyper::Error),
#[cfg(feature = "client")]
#[error("ServiceError: {0}")]
Service(#[source] tower::BoxError),
#[error("configured proxy {proxy_url:?} uses an unsupported protocol")]
ProxyProtocolUnsupported {
proxy_url: Uri,
},
#[error("configured proxy {proxy_url:?} requires the disabled feature {protocol_feature:?}")]
ProxyProtocolDisabled {
proxy_url: Uri,
protocol_feature: &'static str,
},
#[error("UTF-8 Error: {0}")]
FromUtf8(#[source] std::string::FromUtf8Error),
#[error("Error finding newline character")]
LinesCodecMaxLineLengthExceeded,
#[error("Error reading events stream: {0}")]
ReadEvents(#[source] std::io::Error),
#[error("HttpError: {0}")]
HttpError(#[source] http::Error),
#[error("Error deserializing response: {0}")]
SerdeError(#[source] serde_json::Error),
#[error("Failed to build request: {0}")]
BuildRequest(#[source] kube_core::request::Error),
#[error("Failed to infer configuration: {0}")]
InferConfig(#[source] crate::config::InferConfigError),
#[error("Error from discovery: {0}")]
Discovery(#[source] DiscoveryError),
#[cfg(feature = "openssl-tls")]
#[cfg_attr(docsrs, doc(cfg(feature = "openssl-tls")))]
#[error("openssl tls error: {0}")]
OpensslTls(#[source] crate::client::OpensslTlsError),
#[cfg(feature = "rustls-tls")]
#[cfg_attr(docsrs, doc(cfg(feature = "rustls-tls")))]
#[error("rustls tls error: {0}")]
RustlsTls(#[source] crate::client::RustlsTlsError),
#[error("TLS required but no TLS stack selected")]
TlsRequired,
#[cfg(feature = "ws")]
#[cfg_attr(docsrs, doc(cfg(feature = "ws")))]
#[error("failed to upgrade to a WebSocket connection: {0}")]
UpgradeConnection(#[source] crate::client::UpgradeConnectionError),
#[cfg(feature = "client")]
#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
#[error("auth error: {0}")]
Auth(#[source] crate::client::AuthError),
#[cfg(feature = "unstable-client")]
#[cfg_attr(docsrs, doc(cfg(feature = "unstable-client")))]
#[error("Reference resolve error: {0}")]
RefResolve(String),
}
#[derive(Error, Debug)]
pub enum DiscoveryError {
#[error("Invalid GroupVersion: {0}")]
InvalidGroupVersion(String),
#[error("Missing Kind: {0}")]
MissingKind(String),
#[error("Missing Api Group: {0}")]
MissingApiGroup(String),
#[error("Missing Resource: {0}")]
MissingResource(String),
#[error("Empty Api Group: {0}")]
EmptyApiGroup(String),
}