Module aws_error

Module aws_error 

Source
Expand description

Helpers for diagnosing AWS SDK errors.

SdkError’s Display impl collapses everything below the SDK (DNS, TCP, TLS, connector pool, credential providers) into a single short string like "dispatch failure", which makes prod logs nearly useless for distinguishing root causes.

This module provides two utilities meant to be paired at every AWS SDK call-site:

  • classify_sdk_error — returns a stable, low-cardinality &'static str suitable for a tracing field or metric label, distinguishing the actionable subcategories of DispatchFailure (timeout / io / user / other) from TimeoutError, ServiceError, etc.
  • DisplayErrorContext — re-export of the SDK’s own helper that walks the full std::error::Error::source() chain so the underlying cause (e.g., connect timed out, dns error: failed to lookup address) appears in the log instead of just the top-level wrapper.

§Caution: log-only — do not embed in returned error values

DisplayErrorContext walks the underlying SDK chain and can surface internal infrastructure details (endpoint URLs, connector kinds, credential-provider failures). Keep it confined to tracing fields and metrics. For error values returned to upstream callers — which ultimately reach API clients via ApiError::InternalError(err.to_string()) — prefer the stable kind tag from classify_sdk_error.

Typical usage:

tracing::error!(
    error.kind = classify_sdk_error(&err),
    error.detail = %DisplayErrorContext(&err),
    "AWS call failed"
);
// Returned error value carries only the kind tag, not the full chain:
return Err(MyError::Wrapped(format!("op X failed: {}", classify_sdk_error(&err))));

Structs§

DisplayErrorContext
Provides a Display impl for an Error that outputs the full error context

Functions§

classify_sdk_error
Classify an [SdkError] into a stable, low-cardinality kind tag.