pub struct AwsError(/* private fields */);Expand description
Compact pointer-sized error type (size_of::<AwsError>() == size_of::<usize>()).
Boxing the inner payload keeps Result<T, AwsError> and async future state
machines minimal on the stack on the happy path.
Implementations§
Source§impl AwsError
impl AwsError
Sourcepub fn new(
kind: AwsErrorKind,
message: impl Into<Cow<'static, str>>,
correlation_id: impl Into<Cow<'static, str>>,
retryability: Retryability,
) -> Self
pub fn new( kind: AwsErrorKind, message: impl Into<Cow<'static, str>>, correlation_id: impl Into<Cow<'static, str>>, retryability: Retryability, ) -> Self
Creates an AwsError with full control over classification, retryability, and details.
Sourcepub fn validation(
message: impl Into<Cow<'static, str>>,
correlation_id: impl Into<Cow<'static, str>>,
) -> Self
pub fn validation( message: impl Into<Cow<'static, str>>, correlation_id: impl Into<Cow<'static, str>>, ) -> Self
Creates a non-retryable validation error.
Sourcepub fn credentials(
message: impl Into<Cow<'static, str>>,
correlation_id: impl Into<Cow<'static, str>>,
) -> Self
pub fn credentials( message: impl Into<Cow<'static, str>>, correlation_id: impl Into<Cow<'static, str>>, ) -> Self
Creates a non-retryable credentials resolution error.
Sourcepub fn signing(
message: impl Into<Cow<'static, str>>,
correlation_id: impl Into<Cow<'static, str>>,
) -> Self
pub fn signing( message: impl Into<Cow<'static, str>>, correlation_id: impl Into<Cow<'static, str>>, ) -> Self
Creates a non-retryable SigV4 signing error.
Sourcepub fn transport(
message: impl Into<Cow<'static, str>>,
correlation_id: impl Into<Cow<'static, str>>,
) -> Self
pub fn transport( message: impl Into<Cow<'static, str>>, correlation_id: impl Into<Cow<'static, str>>, ) -> Self
Creates a retryable transport error.
Sourcepub fn timeout(
message: impl Into<Cow<'static, str>>,
correlation_id: impl Into<Cow<'static, str>>,
) -> Self
pub fn timeout( message: impl Into<Cow<'static, str>>, correlation_id: impl Into<Cow<'static, str>>, ) -> Self
Creates a retryable timeout error.
Sourcepub fn serialization(
message: impl Into<Cow<'static, str>>,
correlation_id: impl Into<Cow<'static, str>>,
) -> Self
pub fn serialization( message: impl Into<Cow<'static, str>>, correlation_id: impl Into<Cow<'static, str>>, ) -> Self
Creates a non-retryable request serialization error.
Sourcepub fn deserialization(
message: impl Into<Cow<'static, str>>,
correlation_id: impl Into<Cow<'static, str>>,
) -> Self
pub fn deserialization( message: impl Into<Cow<'static, str>>, correlation_id: impl Into<Cow<'static, str>>, ) -> Self
Creates a non-retryable response deserialization error.
Sourcepub fn service(
kind: AwsErrorKind,
details: ServiceErrorDetails,
correlation_id: impl Into<Cow<'static, str>>,
retryability: Retryability,
) -> Self
pub fn service( kind: AwsErrorKind, details: ServiceErrorDetails, correlation_id: impl Into<Cow<'static, str>>, retryability: Retryability, ) -> Self
Creates a structured AWS service error.
Sourcepub fn not_found(
message: impl Into<Cow<'static, str>>,
correlation_id: impl Into<Cow<'static, str>>,
) -> Self
pub fn not_found( message: impl Into<Cow<'static, str>>, correlation_id: impl Into<Cow<'static, str>>, ) -> Self
Creates a non-retryable resource-not-found error.
Sourcepub fn already_exists(
message: impl Into<Cow<'static, str>>,
correlation_id: impl Into<Cow<'static, str>>,
) -> Self
pub fn already_exists( message: impl Into<Cow<'static, str>>, correlation_id: impl Into<Cow<'static, str>>, ) -> Self
Creates a non-retryable already-exists error.
Sourcepub fn throttled(
message: impl Into<Cow<'static, str>>,
correlation_id: impl Into<Cow<'static, str>>,
retry_after: Option<Duration>,
) -> Self
pub fn throttled( message: impl Into<Cow<'static, str>>, correlation_id: impl Into<Cow<'static, str>>, retry_after: Option<Duration>, ) -> Self
Creates a retryable throttling error with optional Retry-After hint.
Sourcepub fn waiter_timeout(
message: impl Into<Cow<'static, str>>,
correlation_id: impl Into<Cow<'static, str>>,
) -> Self
pub fn waiter_timeout( message: impl Into<Cow<'static, str>>, correlation_id: impl Into<Cow<'static, str>>, ) -> Self
Creates a waiter timeout error.
Sourcepub fn waiter_cancelled(
message: impl Into<Cow<'static, str>>,
correlation_id: impl Into<Cow<'static, str>>,
) -> Self
pub fn waiter_cancelled( message: impl Into<Cow<'static, str>>, correlation_id: impl Into<Cow<'static, str>>, ) -> Self
Creates a waiter cancellation error.
Sourcepub fn batch_partial_failure(
message: impl Into<Cow<'static, str>>,
correlation_id: impl Into<Cow<'static, str>>,
) -> Self
pub fn batch_partial_failure( message: impl Into<Cow<'static, str>>, correlation_id: impl Into<Cow<'static, str>>, ) -> Self
Creates a batch partial-failure error.
Sourcepub fn with_details(self, details: impl Into<Cow<'static, str>>) -> Self
pub fn with_details(self, details: impl Into<Cow<'static, str>>) -> Self
Attaches internal diagnostic details, subject to boundary redaction.
Sourcepub fn with_service_error(self, service_error: ServiceErrorDetails) -> Self
pub fn with_service_error(self, service_error: ServiceErrorDetails) -> Self
Attaches structured AWS service error details.
Sourcepub fn with_retryability(self, retryability: Retryability) -> Self
pub fn with_retryability(self, retryability: Retryability) -> Self
Overrides the retryability classification of this error.
Sourcepub fn redact_for_boundary(self, expose_details: bool) -> Self
pub fn redact_for_boundary(self, expose_details: bool) -> Self
Strips internal details unless expose_details is explicitly true.
Source§impl AwsError
impl AwsError
Sourcepub fn kind(&self) -> AwsErrorKind
pub fn kind(&self) -> AwsErrorKind
Returns the error classification.
Sourcepub fn is_not_found(&self) -> bool
pub fn is_not_found(&self) -> bool
Returns true when the target resource or key was not found.
Sourcepub fn is_already_exists(&self) -> bool
pub fn is_already_exists(&self) -> bool
Returns true when resource creation failed because it already exists.
Sourcepub fn is_throttled(&self) -> bool
pub fn is_throttled(&self) -> bool
Returns true when the request was throttled by the AWS service or retry budget.
Sourcepub fn is_timeout(&self) -> bool
pub fn is_timeout(&self) -> bool
Returns true when either an HTTP call or a waiter timed out.
Sourcepub fn is_credentials(&self) -> bool
pub fn is_credentials(&self) -> bool
Returns true when credential resolution or authorization failed.
Sourcepub fn is_validation(&self) -> bool
pub fn is_validation(&self) -> bool
Returns true when client-side validation failed before sending a request.
Sourcepub fn http_status(&self) -> Option<u16>
pub fn http_status(&self) -> Option<u16>
Returns the HTTP status code reported by the AWS service, if available.
Sourcepub fn error_code(&self) -> Option<&str>
pub fn error_code(&self) -> Option<&str>
Returns the structured AWS service error code (e.g. "NoSuchBucket"), if available.
Sourcepub fn request_id(&self) -> Option<&str>
pub fn request_id(&self) -> Option<&str>
Returns the AWS request identifier (x-amz-request-id / x-amzn-requestid), if available.
Sourcepub fn correlation_id(&self) -> &str
pub fn correlation_id(&self) -> &str
Returns the correlation identifier for tracing across retries and waiters.
Sourcepub fn service_error(&self) -> Option<&ServiceErrorDetails>
pub fn service_error(&self) -> Option<&ServiceErrorDetails>
Returns structured AWS service error details, if any.
Sourcepub fn retryability(&self) -> Retryability
pub fn retryability(&self) -> Retryability
Returns retryability metadata.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Returns true if the error is retryable.
Trait Implementations§
impl Eq for AwsError
Source§impl Error for AwsError
impl Error for AwsError
1.30.0 · 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()