Skip to content

Commit 10a1967

Browse files
committed
Avoid using InterceptorError in Interceptor impl
This commit incorporates the following feedback: #2577 (comment) #2577 (comment) #2577 (comment) #2577 (comment)
1 parent 80f25d4 commit 10a1967

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

codegen-client/src/main/kotlin/software/amazon/smithy/rust/codegen/client/smithy/endpoint/generators/EndpointParamsInterceptorGenerator.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ class EndpointParamsInterceptorGenerator(
8383
let input = context.input()?;
8484
let _input = input
8585
.downcast_ref::<${operationInput.name}>()
86-
.ok_or_else(|| #{InterceptorError}::invalid_input_access())?;
86+
.ok_or_else(|| "failed to downcast to ${operationInput.name}")?;
8787
let params_builder = cfg
8888
.get::<#{ParamsBuilder}>()
89-
.ok_or(#{InterceptorError}::read_before_execution("missing endpoint params builder"))?
89+
.ok_or_else(|| "missing endpoint params builder".to_owned())?
9090
.clone();
9191
${"" /* TODO(EndpointResolver): Call setters on `params_builder` to update its fields by using values from `_input` */}
9292
cfg.put(params_builder);
@@ -111,7 +111,7 @@ class EndpointParamsInterceptorGenerator(
111111
)
112112
withBlockTemplate(
113113
"let endpoint_prefix = ",
114-
".map_err(#{InterceptorError}::read_before_execution)?;",
114+
""".map_err(|err| format!("endpoint prefix could not be built: {err:?}"))?;""",
115115
*codegenScope,
116116
) {
117117
endpointTraitBindings.render(
@@ -130,11 +130,11 @@ class EndpointParamsInterceptorGenerator(
130130
let _ = context;
131131
let params_builder = cfg
132132
.get::<#{ParamsBuilder}>()
133-
.ok_or(#{InterceptorError}::read_before_execution("missing endpoint params builder"))?
133+
.ok_or_else(|| "missing endpoint params builder".to_owned())?
134134
.clone();
135135
let params = params_builder
136136
.build()
137-
.map_err(#{InterceptorError}::read_before_execution)?;
137+
.map_err(|err| format!("endpoint params could not be built: {err:?}"))?;
138138
cfg.put(
139139
#{EndpointResolverParams}::new(params)
140140
);

0 commit comments

Comments
 (0)