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    /// Rustls could not enable its safe protocol-version set for deterministic roots.
9    WebPkiRootsProtocolConfigurationFailed,
10    /// Reqwest rejected the fixed hardened client configuration.
11    ClientBuildFailed,
12    /// The bearer credential is bound to a different transport endpoint.
13    CredentialEndpointMismatch,
14}
15
16impl_static_error!(BuildError,
17    Self::ProtocolConfigurationFailed => "TLS protocol configuration failed",
18    Self::PlatformVerifierConfigurationFailed => "platform verifier configuration failed",
19    Self::WebPkiRootsProtocolConfigurationFailed => "web PKI protocol configuration failed",
20    Self::ClientBuildFailed => "HTTP client construction failed",
21    Self::CredentialEndpointMismatch => "credential endpoint differs from transport endpoint",
22);
23
24/// Payload-free transport failure.
25#[derive(Clone, Copy, Debug, Eq, PartialEq)]
26pub enum TransportError {
27    /// The shared credential state could not be read safely.
28    CredentialStateUnavailable,
29    /// Authentication was attempted against a non-HTTPS endpoint.
30    InsecureAuthenticationEndpoint,
31    /// The operation authentication endpoint differs from the configured endpoint.
32    AuthenticationEndpointMismatch,
33    /// The credential scope failed provider or operation policy.
34    AuthenticationScopeRejected,
35    /// The target could not be composed without parsing or normalization.
36    TargetRejected,
37    /// The validated SDK method could not be represented by the HTTP implementation.
38    MethodRejected,
39    /// A non-empty body omitted its required explicit content type.
40    MissingContentType,
41    /// A validated header could not be represented by the HTTP implementation.
42    HeaderRejected,
43    /// Adapter-owned request-body allocation failed.
44    RequestBodyAllocationFailed,
45    /// The request body length cannot be represented by the HTTP client.
46    RequestBodyTooLarge,
47    /// Adapter-owned response-body allocation failed.
48    ResponseBodyAllocationFailed,
49    /// Connection establishment failed.
50    ConnectFailed,
51    /// The configured request or read deadline expired.
52    TimedOut,
53    /// Sending failed for another payload-free reason.
54    RequestFailed,
55    /// The response status is outside the core SDK's admitted HTTP range.
56    InvalidStatus,
57    /// The response content type was duplicated, non-textual, or malformed.
58    InvalidResponseContentType,
59    /// Response headers exceeded bounds, contained controls, or were duplicated.
60    InvalidResponseHeaders,
61    /// The declared or observed response body exceeds the caller buffer.
62    ResponseTooLarge,
63    /// Reading the response body failed.
64    ResponseReadFailed,
65    /// The admitted core response writer rejected the completed response.
66    ResponseCommitFailed,
67    /// The final response origin differed from the configured endpoint.
68    ResponseOriginChanged,
69    /// The bounded raw HTTP executor rejected or failed the request.
70    RawHttp(RawHttpError),
71}
72
73impl_static_error!(TransportError,
74    Self::CredentialStateUnavailable => "credential state is unavailable",
75    Self::InsecureAuthenticationEndpoint => "authenticated transport endpoint is not HTTPS",
76    Self::AuthenticationEndpointMismatch => "authentication endpoint differs from transport endpoint",
77    Self::AuthenticationScopeRejected => "bearer credential scope was rejected",
78    Self::TargetRejected => "request target was rejected",
79    Self::MethodRejected => "request method was rejected",
80    Self::MissingContentType => "request body content type is missing",
81    Self::HeaderRejected => "request header was rejected",
82    Self::RequestBodyAllocationFailed => "request-body allocation failed",
83    Self::RequestBodyTooLarge => "request body is too large",
84    Self::ResponseBodyAllocationFailed => "response-body allocation failed",
85    Self::ConnectFailed => "connection failed",
86    Self::TimedOut => "request timed out",
87    Self::RequestFailed => "request failed",
88    Self::InvalidStatus => "response status is invalid",
89    Self::InvalidResponseContentType => "response content type is invalid",
90    Self::InvalidResponseHeaders => "response headers are invalid",
91    Self::ResponseTooLarge => "response body exceeds the caller limit",
92    Self::ResponseReadFailed => "response body read failed",
93    Self::ResponseCommitFailed => "response commitment failed",
94    Self::ResponseOriginChanged => "response origin changed",
95    Self::RawHttp(_) => "bounded raw HTTP execution failed",
96);
97use super::RawHttpError;