pub struct CredentialsError { /* private fields */ }Expand description
Represents an error creating or using a Credentials.
The Google Cloud client libraries may experience problems creating credentials and/or using them. An example of problems creating credentials may be a badly formatted or missing key file. An example of problems using credentials may be a temporary failure to retrieve or create access tokens. Note that the latter kind of errors may happen even after the credentials files are successfully loaded and parsed.
Applications rarely need to create instances of this error type. The exception might be when testing application code, where the application is mocking a client library behavior. Such tests are extremely rare, most applications should only work with the Error type.
§Example
let err = CredentialsError::from_str(
true, "simulated retryable error while trying to create credentials");
assert!(err.is_retryable());
assert!(format!("{err}").contains("simulated retryable error"));Implementations§
Source§impl CredentialsError
impl CredentialsError
Sourcepub fn new<T>(is_retryable: bool, source: T) -> CredentialsError
pub fn new<T>(is_retryable: bool, source: T) -> CredentialsError
Creates a new CredentialsError.
This function is only intended for use in the client libraries implementation. Application may use this in mocks, though we do not recommend that you write tests for specific error cases. Most tests should use the generic Error type.
§Example
let err = CredentialsError::new(
false, Error::other("simulated non-retryable error while trying to create credentials"));
assert!(!err.is_retryable());
assert!(format!("{err}").contains("simulated non-retryable error"));§Arguments
is_retryable- A boolean indicating whether the error is retryable.source- The underlying error that caused the auth failure.
Sourcepub fn from_str<T>(is_retryable: bool, message: T) -> CredentialsError
pub fn from_str<T>(is_retryable: bool, message: T) -> CredentialsError
Creates a new CredentialsError.
This function is only intended for use in the client libraries implementation. Application may use this in mocks, though we do not recommend that you write tests for specific error cases. Most tests should use the generic Error type.
§Example
let err = CredentialsError::from_str(
true, "simulated retryable error while trying to create credentials");
assert!(err.is_retryable());
assert!(format!("{err}").contains("simulated retryable error"));§Arguments
is_retryable- A boolean indicating whether the error is retryable.message- The underlying error that caused the auth failure.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns true if the error is retryable; otherwise returns false.
Trait Implementations§
Source§impl Clone for CredentialsError
impl Clone for CredentialsError
Source§fn clone(&self) -> CredentialsError
fn clone(&self) -> CredentialsError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more