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}
27
28impl_static_error!(BuildError,
29    Self::ProtocolConfigurationFailed => "TLS protocol configuration failed",
30    Self::PlatformVerifierConfigurationFailed => "platform verifier configuration failed",
31    Self::FipsTlsPolicyRequired => "FIPS TLS policy is required",
32    Self::FipsTrustRootsRequired => "FIPS trust roots are required",
33    Self::FipsCertificateRevocationListsRequired => "FIPS revocation lists are required",
34    Self::FipsProviderRejected => "cryptographic provider did not report FIPS operation",
35    Self::FipsProtocolConfigurationFailed => "FIPS protocol configuration failed",
36    Self::FipsRevocationVerifierFailed => "FIPS revocation verifier configuration failed",
37    Self::FipsClientConfigurationRejected => "TLS client did not report FIPS operation",
38    Self::WebPkiRootsProtocolConfigurationFailed => "web PKI protocol configuration failed",
39    Self::ClientBuildFailed => "HTTP client construction failed",
40);
41
42/// Payload-free transport failure.
43#[derive(Clone, Copy, Debug, Eq, PartialEq)]
44pub enum TransportError {
45    /// The shared credential state could not be read safely.
46    CredentialStateUnavailable,
47    /// The target could not be composed without parsing or normalization.
48    TargetRejected,
49    /// The validated SDK method could not be represented by the HTTP implementation.
50    MethodRejected,
51    /// A non-empty body omitted its required explicit content type.
52    MissingContentType,
53    /// A validated header could not be represented by the HTTP implementation.
54    HeaderRejected,
55    /// Adapter-owned request-body allocation failed.
56    RequestBodyAllocationFailed,
57    /// The request body length cannot be represented by the HTTP client.
58    RequestBodyTooLarge,
59    /// Adapter-owned response-body allocation failed.
60    ResponseBodyAllocationFailed,
61    /// Connection establishment failed.
62    ConnectFailed,
63    /// The configured request or read deadline expired.
64    TimedOut,
65    /// Sending failed for another payload-free reason.
66    RequestFailed,
67    /// The response status is outside the core SDK's admitted HTTP range.
68    InvalidStatus,
69    /// Rate-limit response headers were incomplete, non-decimal, or incoherent.
70    InvalidRateLimitHeaders,
71    /// The response content type was duplicated, non-textual, or malformed.
72    InvalidResponseContentType,
73    /// Response headers exceeded bounds, contained controls, or were duplicated.
74    InvalidResponseHeaders,
75    /// The declared or observed response body exceeds the caller buffer.
76    ResponseTooLarge,
77    /// Reading the response body failed.
78    ResponseReadFailed,
79    /// The admitted core response writer rejected the completed response.
80    ResponseCommitFailed,
81    /// The final response origin differed from the configured endpoint.
82    ResponseOriginChanged,
83}
84
85impl_static_error!(TransportError,
86    Self::CredentialStateUnavailable => "credential state is unavailable",
87    Self::TargetRejected => "request target was rejected",
88    Self::MethodRejected => "request method was rejected",
89    Self::MissingContentType => "request body content type is missing",
90    Self::HeaderRejected => "request header was rejected",
91    Self::RequestBodyAllocationFailed => "request-body allocation failed",
92    Self::RequestBodyTooLarge => "request body is too large",
93    Self::ResponseBodyAllocationFailed => "response-body allocation failed",
94    Self::ConnectFailed => "connection failed",
95    Self::TimedOut => "request timed out",
96    Self::RequestFailed => "request failed",
97    Self::InvalidStatus => "response status is invalid",
98    Self::InvalidRateLimitHeaders => "rate-limit headers are invalid",
99    Self::InvalidResponseContentType => "response content type is invalid",
100    Self::InvalidResponseHeaders => "response headers are invalid",
101    Self::ResponseTooLarge => "response body exceeds the caller limit",
102    Self::ResponseReadFailed => "response body read failed",
103    Self::ResponseCommitFailed => "response commitment failed",
104    Self::ResponseOriginChanged => "response origin changed",
105);