pub struct AwsError {
pub status: StatusCode,
pub code: String,
pub message: String,
pub error_type: ErrorType,
pub extras: Option<Box<Map<String, Value>>>,
}Expand description
Represents an AWS API error response.
Fields§
§status: StatusCodeHTTP status code (e.g., 404, 400, 500)
code: StringAWS error code (e.g., “NoSuchBucket”, “ResourceNotFoundException”)
message: StringHuman-readable error message
error_type: ErrorTypeError type: “Sender” (client error) or “Receiver” (server error)
extras: Option<Box<Map<String, Value>>>Extra JSON fields merged into the serialized error body.
Some AWS exceptions carry structured data alongside the standard
__type / message envelope — for example, DynamoDB’s
TransactionCanceledException includes a CancellationReasons array,
and ConditionalCheckFailedException may include the existing Item.
Use Self::with_extras or Self::with_extra to attach them.
Boxed to keep AwsError small enough to fit comfortably in a
Result<_, AwsError> (clippy’s result_large_err threshold).
Implementations§
Source§impl AwsError
impl AwsError
pub fn not_found(code: impl Into<String>, message: impl Into<String>) -> Self
Sourcepub fn service_not_found(
code: impl Into<String>,
message: impl Into<String>,
) -> Self
pub fn service_not_found( code: impl Into<String>, message: impl Into<String>, ) -> Self
Service-level “resource not found” error returned with HTTP 400.
Many JSON-protocol services (DynamoDB, KMS, SecretsManager, Cognito, …)
model ResourceNotFoundException and friends as client-side validation
errors and respond with 400 Bad Request rather than 404 Not Found.
Use this constructor for those cases; reserve Self::not_found for
REST-style 404s such as S3’s NoSuchBucket / NoSuchKey.
pub fn bad_request(code: impl Into<String>, message: impl Into<String>) -> Self
pub fn conflict(code: impl Into<String>, message: impl Into<String>) -> Self
pub fn internal(message: impl Into<String>) -> Self
pub fn not_implemented(operation: &str) -> Self
pub fn unknown_operation(operation: &str) -> Self
pub fn access_denied(message: impl Into<String>) -> Self
pub fn access_denied_for( action: &str, principal_arn: &str, resource: &str, ) -> Self
pub fn validation(message: impl Into<String>) -> Self
Sourcepub fn with_extras(self, extras: Map<String, Value>) -> Self
pub fn with_extras(self, extras: Map<String, Value>) -> Self
Replace the extras map wholesale.
Sourcepub fn with_extra(self, key: impl Into<String>, value: Value) -> Self
pub fn with_extra(self, key: impl Into<String>, value: Value) -> Self
Insert a single extra field, allocating the map if needed.
Trait Implementations§
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()