smithy-lang / smithy-rs

Code generation for the AWS SDK for Rust, as well as server and generic smithy client generation.
Apache License 2.0
467 stars 183 forks source link

Stop serializing server framework-level errors manually #3716

Open david-perez opened 5 days ago

david-perez commented 5 days ago

We're currently serializing server framework-level errors manually. We're doing this for each protocol. For example, for restJson1:

https://github.com/smithy-lang/smithy-rs/blob/b74887861280ec475db984f9a7603eebb4d959b9/rust-runtime/aws-smithy-http-server/src/protocol/rest_json_1/runtime_error.rs#L92-L108

Instead of manually writing this serialization code, we should model these errors as Smithy structure shapes with the @error trait, adjoin them automatically to all models, and leverage the code-generated serializers. This is the approach that smithy-typescript uses.

This has the advantage of reducing the amount of code that we need to maintain, and reducing possible bugs introduced in the manual implementations that don't honor the protocol specifications.