Skip to main content

cloud_sdk_reqwest/shared/
error.rs

1/// Client construction failure.
2#[derive(Clone, Copy, Debug, Eq, PartialEq)]
3pub enum BuildError {
4    /// Rustls could not enable its safe protocol-version set.
5    ProtocolConfigurationFailed,
6    /// The operating-system trust verifier could not be configured.
7    PlatformVerifierConfigurationFailed,
8    /// FIPS transport construction omitted its required trust and revocation policy.
9    FipsTlsPolicyRequired,
10    /// The FIPS trust policy contained no trust anchors.
11    FipsTrustRootsRequired,
12    /// The FIPS trust policy contained no certificate revocation lists.
13    FipsCertificateRevocationListsRequired,
14    /// The selected cryptographic provider did not report FIPS operation.
15    FipsProviderRejected,
16    /// Rustls could not enable its safe protocol-version set for the FIPS provider.
17    FipsProtocolConfigurationFailed,
18    /// The chain-wide, fail-closed certificate revocation verifier could not be configured.
19    FipsRevocationVerifierFailed,
20    /// The complete TLS client configuration did not report FIPS operation.
21    FipsClientConfigurationRejected,
22    /// Rustls could not enable its safe protocol-version set for deterministic roots.
23    WebPkiRootsProtocolConfigurationFailed,
24    /// Reqwest rejected the fixed hardened client configuration.
25    ClientBuildFailed,
26    /// The bearer credential is bound to a different transport endpoint.
27    CredentialEndpointMismatch,
28}
29
30impl_static_error!(BuildError,
31    Self::ProtocolConfigurationFailed => "TLS protocol configuration failed",
32    Self::PlatformVerifierConfigurationFailed => "platform verifier configuration failed",
33    Self::FipsTlsPolicyRequired => "FIPS TLS policy is required",
34    Self::FipsTrustRootsRequired => "FIPS trust roots are required",
35    Self::FipsCertificateRevocationListsRequired => "FIPS revocation lists are required",
36    Self::FipsProviderRejected => "cryptographic provider did not report FIPS operation",
37    Self::FipsProtocolConfigurationFailed => "FIPS protocol configuration failed",
38    Self::FipsRevocationVerifierFailed => "FIPS revocation verifier configuration failed",
39    Self::FipsClientConfigurationRejected => "TLS client did not report FIPS operation",
40    Self::WebPkiRootsProtocolConfigurationFailed => "web PKI protocol configuration failed",
41    Self::ClientBuildFailed => "HTTP client construction failed",
42    Self::CredentialEndpointMismatch => "credential endpoint differs from transport endpoint",
43);
44
45/// Payload-free transport failure.
46#[derive(Clone, Copy, Debug, Eq, PartialEq)]
47pub enum TransportError {
48    /// The shared credential state could not be read safely.
49    CredentialStateUnavailable,
50    /// Authentication was attempted against a non-HTTPS endpoint.
51    InsecureAuthenticationEndpoint,
52    /// The operation authentication endpoint differs from the configured endpoint.
53    AuthenticationEndpointMismatch,
54    /// The credential scope failed provider or operation policy.
55    AuthenticationScopeRejected,
56    /// The target could not be composed without parsing or normalization.
57    TargetRejected,
58    /// The validated SDK method could not be represented by the HTTP implementation.
59    MethodRejected,
60    /// A non-empty body omitted its required explicit content type.
61    MissingContentType,
62    /// A validated header could not be represented by the HTTP implementation.
63    HeaderRejected,
64    /// Adapter-owned request-body allocation failed.
65    RequestBodyAllocationFailed,
66    /// The request body length cannot be represented by the HTTP client.
67    RequestBodyTooLarge,
68    /// Adapter-owned response-body allocation failed.
69    ResponseBodyAllocationFailed,
70    /// Connection establishment failed.
71    ConnectFailed,
72    /// The configured request or read deadline expired.
73    TimedOut,
74    /// Sending failed for another payload-free reason.
75    RequestFailed,
76    /// The response status is outside the core SDK's admitted HTTP range.
77    InvalidStatus,
78    /// Rate-limit response headers were incomplete, non-decimal, or incoherent.
79    InvalidRateLimitHeaders,
80    /// The response content type was duplicated, non-textual, or malformed.
81    InvalidResponseContentType,
82    /// Response headers exceeded bounds, contained controls, or were duplicated.
83    InvalidResponseHeaders,
84    /// The declared or observed response body exceeds the caller buffer.
85    ResponseTooLarge,
86    /// Reading the response body failed.
87    ResponseReadFailed,
88    /// The admitted core response writer rejected the completed response.
89    ResponseCommitFailed,
90    /// The final response origin differed from the configured endpoint.
91    ResponseOriginChanged,
92}
93
94impl_static_error!(TransportError,
95    Self::CredentialStateUnavailable => "credential state is unavailable",
96    Self::InsecureAuthenticationEndpoint => "authenticated transport endpoint is not HTTPS",
97    Self::AuthenticationEndpointMismatch => "authentication endpoint differs from transport endpoint",
98    Self::AuthenticationScopeRejected => "bearer credential scope was rejected",
99    Self::TargetRejected => "request target was rejected",
100    Self::MethodRejected => "request method was rejected",
101    Self::MissingContentType => "request body content type is missing",
102    Self::HeaderRejected => "request header was rejected",
103    Self::RequestBodyAllocationFailed => "request-body allocation failed",
104    Self::RequestBodyTooLarge => "request body is too large",
105    Self::ResponseBodyAllocationFailed => "response-body allocation failed",
106    Self::ConnectFailed => "connection failed",
107    Self::TimedOut => "request timed out",
108    Self::RequestFailed => "request failed",
109    Self::InvalidStatus => "response status is invalid",
110    Self::InvalidRateLimitHeaders => "rate-limit headers are invalid",
111    Self::InvalidResponseContentType => "response content type is invalid",
112    Self::InvalidResponseHeaders => "response headers are invalid",
113    Self::ResponseTooLarge => "response body exceeds the caller limit",
114    Self::ResponseReadFailed => "response body read failed",
115    Self::ResponseCommitFailed => "response commitment failed",
116    Self::ResponseOriginChanged => "response origin changed",
117);