Skip to content

Commit

Permalink
Fix the re-export in middleware mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jdisanti committed Aug 18, 2023
1 parent 0b18d88 commit 9605963
Showing 1 changed file with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import software.amazon.smithy.rust.codegen.client.smithy.generators.OperationCus
import software.amazon.smithy.rust.codegen.client.smithy.generators.ServiceRuntimePluginCustomization
import software.amazon.smithy.rust.codegen.client.smithy.generators.config.ConfigCustomization
import software.amazon.smithy.rust.codegen.core.rustlang.Feature
import software.amazon.smithy.rust.codegen.core.rustlang.rust
import software.amazon.smithy.rust.codegen.core.rustlang.rustTemplate
import software.amazon.smithy.rust.codegen.core.smithy.RuntimeType
import software.amazon.smithy.rust.codegen.core.smithy.RustCrate
Expand Down Expand Up @@ -94,18 +95,27 @@ class RequiredCustomizations : ClientCodegenDecorator {
pubUseSmithyPrimitives(codegenContext, codegenContext.model)(this)
}
rustCrate.withModule(ClientRustModule.Error) {
// TODO(enableNewSmithyRuntimeCleanup): Change SdkError to a `pub use` after changing the generic's default
rust("/// Error type returned by the client.")
if (codegenContext.smithyRuntimeMode.generateOrchestrator) {
rustTemplate(
"pub type SdkError<E> = #{SdkError}<E, #{R}>;",
"SdkError" to RuntimeType.sdkError(rc),
"R" to RuntimeType.smithyRuntimeApi(rc).resolve("client::orchestrator::HttpResponse"),
)
} else {
rustTemplate(
"pub type SdkError<E> = #{SdkError}<E, #{R}<#{B}>>;",
"SdkError" to RuntimeType.sdkError(rc),
"R" to RuntimeType.HttpResponse,
"B" to RuntimeType.sdkBody(rc),
)
}
rustTemplate(
"""
pub type SdkError<E> = #{SdkError}<E, #{SdkErrorResponse}>;
pub use #{DisplayErrorContext};
pub use #{ProvideErrorMetadata};
""",
"SdkError" to RuntimeType.smithyHttp(rc).resolve("result::SdkError"),
"SdkErrorResponse" to if (codegenContext.smithyRuntimeMode.generateOrchestrator) {
RuntimeType.smithyRuntimeApi(rc).resolve("client::orchestrator::HttpResponse")
} else {
RuntimeType.HttpResponse
},
"DisplayErrorContext" to RuntimeType.smithyTypes(rc).resolve("error::display::DisplayErrorContext"),
"ProvideErrorMetadata" to RuntimeType.smithyTypes(rc).resolve("error::metadata::ProvideErrorMetadata"),
)
Expand Down

0 comments on commit 9605963

Please sign in to comment.