1use crate::{JwtBundleError, JwtSvidError, SpiffeIdError, X509BundleError, X509SvidError};
4use thiserror::Error;
5use url::ParseError;
6
7#[derive(Debug, Error)]
9#[non_exhaustive]
10pub enum GrpcClientError {
11 #[error("missing SPIFFE_ENDPOINT_SOCKET")]
13 MissingEndpointSocketPath,
14
15 #[error("empty Workload API response")]
17 EmptyResponse,
18
19 #[error("invalid endpoint socket path")]
21 InvalidEndpointSocketPath(#[from] SocketPathError),
22
23 #[error("x509 svid parse error")]
25 X509Svid(#[from] X509SvidError),
26
27 #[error("jwt svid parse error")]
29 JwtSvid(#[from] JwtSvidError),
30
31 #[error("x509 bundle parse error")]
33 X509Bundle(#[from] X509BundleError),
34
35 #[error("jwt bundle parse error")]
37 JwtBundle(#[from] JwtBundleError),
38
39 #[error("spiffe id parse error")]
41 SpiffeId(#[from] SpiffeIdError),
42
43 #[cfg(feature = "workload-api")]
45 #[error("gRPC status: {0}")]
46 Grpc(#[from] tonic::Status),
47
48 #[cfg(feature = "workload-api")]
50 #[error("gRPC transport error: {0}")]
51 Transport(#[from] tonic::transport::Error),
52}
53
54#[derive(Debug, Error, PartialEq, Clone)]
56#[non_exhaustive]
57pub enum SocketPathError {
58 #[error("endpoint socket URI scheme must be tcp:// or unix://")]
60 InvalidScheme,
61
62 #[error("unix:// endpoint socket URI must include a path")]
64 UnixAddressEmptyPath,
65
66 #[error("tcp:// endpoint socket URI must not include a path")]
68 TcpAddressNonEmptyPath,
69
70 #[error("endpoint socket URI must not include query values")]
72 HasQueryValues,
73
74 #[error("endpoint socket URI must not include a fragment")]
76 HasFragment,
77
78 #[error("endpoint socket URI must not include user info")]
80 HasUserInfo,
81
82 #[error("tcp:// endpoint socket URI must include a host")]
84 TcpEmptyHost,
85
86 #[error("tcp:// endpoint socket URI host must be an IP:port")]
88 TcpAddressNoIpPort,
89
90 #[error("endpoint socket is not a valid URI")]
92 Parse(#[from] ParseError),
93}