pub enum Error {
Transport(Error),
Grpc(Box<Status>),
Auth(String),
InvalidUri(String),
InvalidMetadata(InvalidMetadataValue),
}Expand description
All errors that can be returned by the Armada client.
Most callers can pattern-match on the variant that matters to them and
propagate the rest with ?. Use Error::auth as a convenience
constructor when implementing crate::auth::TokenProvider.
§Example
use armada_client::{ArmadaClient, Error, StaticTokenProvider};
async fn submit_or_retry(client: &ArmadaClient) {
// ... build request ...
match client.submit(request).await {
Ok(resp) => { /* handle success */ }
Err(Error::Grpc(status)) => {
// The server returned a non-OK gRPC status (e.g. NOT_FOUND).
eprintln!("gRPC error: {status}");
}
Err(Error::Auth(msg)) => {
// Token provider failed — check credentials.
eprintln!("auth failure: {msg}");
}
Err(e) => eprintln!("other error: {e}"),
}
}Variants§
Transport(Error)
A low-level transport failure occurred before a gRPC response could be received — for example a connection refused, TLS handshake error, or DNS resolution failure.
Grpc(Box<Status>)
The server returned a non-OK gRPC status code.
Common codes:
NOT_FOUND— the requested queue or job set does not exist.PERMISSION_DENIED— the bearer token lacks the required privileges.INVALID_ARGUMENT— the request payload was rejected by the server.
Auth(String)
Returned by custom crate::auth::TokenProvider implementations
to signal that token retrieval failed.
InvalidUri(String)
Returned when the endpoint string passed to
crate::client::ArmadaClient::connect or
crate::client::ArmadaClient::connect_tls is not a valid URI.
InvalidMetadata(InvalidMetadataValue)
The bearer token string contained characters that are not valid in an
HTTP header value. Token strings must be ASCII and must not contain
control characters (\0, \r, \n, etc.).
Implementations§
Source§impl Error
impl Error
Sourcepub fn auth(msg: impl Into<String>) -> Self
pub fn auth(msg: impl Into<String>) -> Self
Convenience constructor for Error::Auth.
Use this in custom crate::auth::TokenProvider implementations:
return Err(Error::auth("token expired"));Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<InvalidMetadataValue> for Error
impl From<InvalidMetadataValue> for Error
Source§fn from(source: InvalidMetadataValue) -> Self
fn from(source: InvalidMetadataValue) -> Self
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl !UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request