Skip to content

Commit

Permalink
Throw a specific exception if the service doesn't have ep rules
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoh committed Dec 14, 2022
1 parent 7536a50 commit d79142c
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

package software.amazon.smithy.rustsdk

import software.amazon.smithy.codegen.core.CodegenException
import software.amazon.smithy.model.Model
import software.amazon.smithy.model.shapes.ServiceShape
import software.amazon.smithy.model.shapes.ShapeId
Expand Down Expand Up @@ -89,8 +90,15 @@ class AwsEndpointDecorator : RustCodegenDecorator<ClientProtocolGenerator, Clien

override fun extras(codegenContext: ClientCodegenContext, rustCrate: RustCrate) {
val epTypes = EndpointTypesGenerator.fromContext(codegenContext)
if (epTypes.defaultResolver() == null) {
throw CodegenException(
"${codegenContext.serviceShape} did not provide endpoint rules. " +
"This is a bug and the generated client will not work. All AWS services MUST define endpoint rules.",
)
}
// generate a region converter if params has a region
if (!epTypes.params.toList().any { it.builtIn == Builtins.REGION.builtIn }) {
println("not generating a resolver for ${codegenContext.serviceShape}")
return
}
rustCrate.withModule(EndpointsModule) {
Expand Down

0 comments on commit d79142c

Please sign in to comment.