@@ -62,15 +62,13 @@ where
6262 . ok_or_else ( || {
6363 handlebars:: RenderErrorReason :: Other ( format ! (
6464 "The `get` helper's first argument must be a string (the route of the content \
65- item to get), but it was `{}`.",
66- param_0,
65+ item to get), but it was `{param_0}`.",
6766 ) )
6867 } ) ?
6968 . parse :: < Route > ( )
7069 . map_err ( |error| {
7170 handlebars:: RenderErrorReason :: Other ( format ! (
72- "The `get` helper's first argument (`{}`) must be a valid route: {}" ,
73- param_0, error,
71+ "The `get` helper's first argument (`{param_0}`) must be a valid route: {error}" ,
7472 ) )
7573 } ) ?;
7674
8179 let param_1_as_object = match param_1. map ( |value| {
8280 value. as_object ( ) . ok_or_else ( || {
8381 handlebars:: RenderErrorReason :: Other ( format ! (
84- "Custom context provided to `get \" {}\" ` must be an object, but it was `{}`." ,
85- route, value,
82+ "Custom context provided to `get \" {route}\" ` must be an object, but it was `{value}`." ,
8683 ) )
8784 } )
8885 } ) {
@@ -109,10 +106,7 @@ where
109106 } ) ;
110107
111108 let content_item = content_engine. get_internal ( & route) . ok_or_else ( || {
112- handlebars:: RenderErrorReason :: Other ( format ! (
113- "No content found for `get \" {}\" `." ,
114- route
115- ) )
109+ handlebars:: RenderErrorReason :: Other ( format ! ( "No content found for `get \" {route}\" `." ) )
116110 } ) ?;
117111
118112 let current_render_data = handlebars_context. data ( ) . as_object ( ) . ok_or_else ( || {
@@ -131,10 +125,8 @@ where
131125 serde_json:: Value :: Object ( modified_context_data_as_json_map) => modified_context_data_as_json_map,
132126 _ => {
133127 return Err ( handlebars:: RenderError :: from ( handlebars:: RenderErrorReason :: Other ( format ! (
134- "The `get \" {}\" ` helper call failed because the pre-existing handlebars render context \
135- was not an object (it was `{}`).",
136- route,
137- modified_context_data_as_json
128+ "The `get \" {route}\" ` helper call failed because the pre-existing handlebars render context \
129+ was not an object (it was `{modified_context_data_as_json}`)."
138130 ) ) ) )
139131 }
140132 }
@@ -166,8 +158,7 @@ where
166158 . render ( context, & [ target_media_type. into_media_range ( ) ] )
167159 . map_err ( |render_error| {
168160 handlebars:: RenderErrorReason :: Other ( format ! (
169- "The `get \" {}\" ` helper call failed because {} could not be rendered: {}" ,
170- route, route, render_error,
161+ "The `get \" {route}\" ` helper call failed because {route} could not be rendered: {render_error}" ,
171162 ) )
172163 } ) ?;
173164
@@ -183,11 +174,8 @@ where
183174 ) )
184175 . map_err ( |streaming_error| {
185176 handlebars:: RenderErrorReason :: Other ( format ! (
186- "The `get \" {}\" ` helper call failed because there was an error collecting the rendered content \
187- for {}: {}",
188- route,
189- route,
190- streaming_error,
177+ "The `get \" {route}\" ` helper call failed because there was an error collecting the rendered content \
178+ for {route}: {streaming_error}",
191179 ) )
192180 } ) ?;
193181 let rendered_content_as_string = String :: from_utf8 ( bytes) ?;
@@ -207,11 +195,9 @@ fn get_target_media_type(
207195 . and_then ( |media_type_essence| media_type_essence. parse :: < MediaType > ( ) . ok ( ) )
208196 . ok_or_else ( || {
209197 handlebars:: RenderErrorReason :: Other ( format ! (
210- "The `get \" {}\" ` helper call failed because a valid target media type could not be found \
211- in the handlebars context. The context JSON must contain a property at `{}` whose value is \
198+ "The `get \" {route }\" ` helper call failed because a valid target media type could not be found \
199+ in the handlebars context. The context JSON must contain a property at `{TARGET_MEDIA_TYPE_PROPERTY_NAME }` whose value is \
212200 a valid media type essence string.",
213- route,
214- TARGET_MEDIA_TYPE_PROPERTY_NAME ,
215201 ) )
216202 } ) ?;
217203 Ok ( target_media_type)
@@ -227,11 +213,9 @@ fn get_optional_request_route(
227213 . and_then ( |request_data| request_data. get ( ROUTE_PROPERTY_NAME ) )
228214 . ok_or_else ( || {
229215 handlebars:: RenderErrorReason :: Other ( format ! (
230- "The `get \" {}\" ` helper call failed because the request route could not be found in the \
231- handlebars context. The context JSON must contain a property at `{}.{}` whose value is a \
232- string or null.",
233- route,
234- REQUEST_DATA_PROPERTY_NAME , ROUTE_PROPERTY_NAME
216+ "The `get \" {route}\" ` helper call failed because the request route could not be found in the \
217+ handlebars context. The context JSON must contain a property at `{REQUEST_DATA_PROPERTY_NAME}.{ROUTE_PROPERTY_NAME}` whose value is a \
218+ string or null."
235219 ) )
236220 } ) ?;
237221
@@ -241,19 +225,15 @@ fn get_optional_request_route(
241225 let request_route = request_route_value. as_str ( )
242226 . ok_or_else ( || {
243227 handlebars:: RenderErrorReason :: Other ( format ! (
244- "The `get \" {}\" ` helper call failed because the request route in the handlebars context was \
245- not a string or null (it was `{}`).",
246- route,
247- request_route_value,
228+ "The `get \" {route}\" ` helper call failed because the request route in the handlebars context was \
229+ not a string or null (it was `{request_route_value}`).",
248230 ) )
249231 } ) ?
250232 . parse :: < Route > ( )
251233 . map_err ( |error| {
252234 handlebars:: RenderErrorReason :: Other ( format ! (
253- "The `get \" {}\" ` helper call failed because the request route in the handlebars context was \
254- invalid ({}).",
255- route,
256- error,
235+ "The `get \" {route}\" ` helper call failed because the request route in the handlebars context was \
236+ invalid ({error}).",
257237 ) )
258238 } ) ?;
259239 Some ( request_route)
@@ -271,19 +251,15 @@ fn get_query_parameters(
271251 . and_then ( |request_data| request_data. get ( QUERY_PARAMETERS_PROPERTY_NAME ) )
272252 . ok_or_else ( || {
273253 handlebars:: RenderErrorReason :: Other ( format ! (
274- "The `get \" {}\" ` helper call failed because the query parameters could not be found in the \
275- handlebars context. The context JSON must contain a property at `{}.{}` whose value is a map.",
276- route,
277- REQUEST_DATA_PROPERTY_NAME ,
278- QUERY_PARAMETERS_PROPERTY_NAME ,
254+ "The `get \" {route}\" ` helper call failed because the query parameters could not be found in the \
255+ handlebars context. The context JSON must contain a property at `{REQUEST_DATA_PROPERTY_NAME}.{QUERY_PARAMETERS_PROPERTY_NAME}` whose value is a map.",
279256 ) )
280257 } ) ?
281258 . as_object ( )
282259 . ok_or_else ( || {
283260 handlebars:: RenderErrorReason :: Other ( format ! (
284- "The `get \" {}\" ` helper call failed because the query parameters in the handlebars context \
261+ "The `get \" {route }\" ` helper call failed because the query parameters in the handlebars context \
285262 was not a map.",
286- route,
287263 ) )
288264 } ) ?
289265 . into_iter ( )
@@ -305,18 +281,14 @@ fn get_request_headers(
305281 . and_then ( |request_data| request_data. get ( REQUEST_HEADERS_PROPERTY_NAME ) )
306282 . ok_or_else ( || {
307283 handlebars:: RenderErrorReason :: Other ( format ! (
308- "The `get \" {}\" ` helper call failed because the request headers could not be found in \
309- the handlebars context. The context JSON must contain a property at `{}.{}` whose value \
310- is a map.",
311- route,
312- REQUEST_DATA_PROPERTY_NAME ,
313- REQUEST_HEADERS_PROPERTY_NAME
284+ "The `get \" {route}\" ` helper call failed because the request headers could not be found in \
285+ the handlebars context. The context JSON must contain a property at `{REQUEST_DATA_PROPERTY_NAME}.{REQUEST_HEADERS_PROPERTY_NAME}` whose value \
286+ is a map."
314287 ) )
315288 } ) ?. as_object ( ) . ok_or_else ( || {
316289 handlebars:: RenderErrorReason :: Other ( format ! (
317- "The `get \" {}\" ` helper call failed because the request headers in the handlebars context \
290+ "The `get \" {route }\" ` helper call failed because the request headers in the handlebars context \
318291 was not a map.",
319- route,
320292 ) )
321293 } ) ?
322294 . into_iter ( )
0 commit comments