Skip to content

Commit

Permalink
Avoid using InterceptorError in Interceptor impl
Browse files Browse the repository at this point in the history
This commit incorporates the following feedback:
#2577 (comment)
#2577 (comment)
#2577 (comment)
#2577 (comment)
  • Loading branch information
ysaito1001 committed Apr 18, 2023
1 parent 80f25d4 commit 10a1967
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ class EndpointParamsInterceptorGenerator(
let input = context.input()?;
let _input = input
.downcast_ref::<${operationInput.name}>()
.ok_or_else(|| #{InterceptorError}::invalid_input_access())?;
.ok_or_else(|| "failed to downcast to ${operationInput.name}")?;
let params_builder = cfg
.get::<#{ParamsBuilder}>()
.ok_or(#{InterceptorError}::read_before_execution("missing endpoint params builder"))?
.ok_or_else(|| "missing endpoint params builder".to_owned())?
.clone();
${"" /* TODO(EndpointResolver): Call setters on `params_builder` to update its fields by using values from `_input` */}
cfg.put(params_builder);
Expand All @@ -111,7 +111,7 @@ class EndpointParamsInterceptorGenerator(
)
withBlockTemplate(
"let endpoint_prefix = ",
".map_err(#{InterceptorError}::read_before_execution)?;",
""".map_err(|err| format!("endpoint prefix could not be built: {err:?}"))?;""",
*codegenScope,
) {
endpointTraitBindings.render(
Expand All @@ -130,11 +130,11 @@ class EndpointParamsInterceptorGenerator(
let _ = context;
let params_builder = cfg
.get::<#{ParamsBuilder}>()
.ok_or(#{InterceptorError}::read_before_execution("missing endpoint params builder"))?
.ok_or_else(|| "missing endpoint params builder".to_owned())?
.clone();
let params = params_builder
.build()
.map_err(#{InterceptorError}::read_before_execution)?;
.map_err(|err| format!("endpoint params could not be built: {err:?}"))?;
cfg.put(
#{EndpointResolverParams}::new(params)
);
Expand Down

0 comments on commit 10a1967

Please sign in to comment.