Skip to content

Error types should not implement source _and_ print inner error in Display #1345

Closed
@jonhoo

Description

@jonhoo

SdkError, and possibly other error types within the SDK, currently expose inner errors both through Error::source and fmt::Display:

https://github.com/awslabs/smithy-rs/blob/692bf94ba30f570365f559c67d6a9981c037c371/rust-runtime/aws-smithy-http/src/result.rs#L176-L206

The recommendation in the ecosystem is to either return inner errors through Error::source or print the inner error in Display, but never both (see rust-lang/project-error-handling#27 (comment), rust-lang/project-error-handling#23, rust-lang/api-guidelines#210), as otherwise errors end up being duplicated whenever error reporters print error backtraces. For example, I recently got an error trace that ended in:

    6: failed to construct request: Failed to load credentials from the credentials provider: An error occurred while loading credentials: io error: error trying to connect: invalid certificate: UnknownIssuer
    7: Failed to load credentials from the credentials provider: An error occurred while loading credentials: io error: error trying to connect: invalid certificate: UnknownIssuer

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingsdk-ga

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions