qcs_api_client_grpc/tonic/
error.rs

1use http::{header::InvalidHeaderValue, uri::InvalidUri};
2use tonic::transport::Error as TransportError;
3
4use qcs_api_client_common::configuration::LoadError;
5
6use super::{channel::ChannelError, RequestBodyDuplicationError};
7
8/// Errors that may occur when using gRPC.
9#[derive(Debug, thiserror::Error)]
10#[allow(variant_size_differences)]
11pub enum Error<E>
12where
13    E: std::error::Error,
14{
15    /// Failed to refresh the access token.
16    #[error("failed to refresh access token: {0}")]
17    Refresh(#[source] E),
18    /// Failed to load the QCS configuration.
19    #[error("failed to load QCS config: {0}")]
20    Load(#[from] LoadError),
21    /// Failed to parse URI.
22    #[error("failed to parse URI: {0}")]
23    InvalidUri(#[from] InvalidUri),
24    /// The gRPC call failed for some reason.
25    #[error("service call failed with error: {0}")]
26    Transport(#[from] TransportError),
27    /// The provided access token is not a valid header value.
28    #[error("access token is not a valid header value: {0}")]
29    InvalidAccessToken(#[source] InvalidHeaderValue),
30    /// The proxy configuration caused an error
31    #[error("The channel configuration caused an error: {0}")]
32    ChannelError(#[from] ChannelError),
33    #[cfg(feature = "grpc-web")]
34    #[error("The hyper grpc-web client returned an error: {0}")]
35    HyperError(#[from] hyper::Error),
36    #[error("failed to duplicate request body for retry: {0}")]
37    CloneBody(#[from] RequestBodyDuplicationError),
38}