@@ -62,15 +62,13 @@ where
62
62
. ok_or_else ( || {
63
63
handlebars:: RenderErrorReason :: Other ( format ! (
64
64
"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}`.",
67
66
) )
68
67
} ) ?
69
68
. parse :: < Route > ( )
70
69
. map_err ( |error| {
71
70
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}" ,
74
72
) )
75
73
} ) ?;
76
74
81
79
let param_1_as_object = match param_1. map ( |value| {
82
80
value. as_object ( ) . ok_or_else ( || {
83
81
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}`." ,
86
83
) )
87
84
} )
88
85
} ) {
@@ -109,10 +106,7 @@ where
109
106
} ) ;
110
107
111
108
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}\" `." ) )
116
110
} ) ?;
117
111
118
112
let current_render_data = handlebars_context. data ( ) . as_object ( ) . ok_or_else ( || {
@@ -131,10 +125,8 @@ where
131
125
serde_json:: Value :: Object ( modified_context_data_as_json_map) => modified_context_data_as_json_map,
132
126
_ => {
133
127
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}`)."
138
130
) ) ) )
139
131
}
140
132
}
@@ -166,8 +158,7 @@ where
166
158
. render ( context, & [ target_media_type. into_media_range ( ) ] )
167
159
. map_err ( |render_error| {
168
160
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}" ,
171
162
) )
172
163
} ) ?;
173
164
@@ -183,11 +174,8 @@ where
183
174
) )
184
175
. map_err ( |streaming_error| {
185
176
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}",
191
179
) )
192
180
} ) ?;
193
181
let rendered_content_as_string = String :: from_utf8 ( bytes) ?;
@@ -207,11 +195,9 @@ fn get_target_media_type(
207
195
. and_then ( |media_type_essence| media_type_essence. parse :: < MediaType > ( ) . ok ( ) )
208
196
. ok_or_else ( || {
209
197
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 \
212
200
a valid media type essence string.",
213
- route,
214
- TARGET_MEDIA_TYPE_PROPERTY_NAME ,
215
201
) )
216
202
} ) ?;
217
203
Ok ( target_media_type)
@@ -227,11 +213,9 @@ fn get_optional_request_route(
227
213
. and_then ( |request_data| request_data. get ( ROUTE_PROPERTY_NAME ) )
228
214
. ok_or_else ( || {
229
215
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."
235
219
) )
236
220
} ) ?;
237
221
@@ -241,19 +225,15 @@ fn get_optional_request_route(
241
225
let request_route = request_route_value. as_str ( )
242
226
. ok_or_else ( || {
243
227
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}`).",
248
230
) )
249
231
} ) ?
250
232
. parse :: < Route > ( )
251
233
. map_err ( |error| {
252
234
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}).",
257
237
) )
258
238
} ) ?;
259
239
Some ( request_route)
@@ -271,19 +251,15 @@ fn get_query_parameters(
271
251
. and_then ( |request_data| request_data. get ( QUERY_PARAMETERS_PROPERTY_NAME ) )
272
252
. ok_or_else ( || {
273
253
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.",
279
256
) )
280
257
} ) ?
281
258
. as_object ( )
282
259
. ok_or_else ( || {
283
260
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 \
285
262
was not a map.",
286
- route,
287
263
) )
288
264
} ) ?
289
265
. into_iter ( )
@@ -305,18 +281,14 @@ fn get_request_headers(
305
281
. and_then ( |request_data| request_data. get ( REQUEST_HEADERS_PROPERTY_NAME ) )
306
282
. ok_or_else ( || {
307
283
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."
314
287
) )
315
288
} ) ?. as_object ( ) . ok_or_else ( || {
316
289
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 \
318
291
was not a map.",
319
- route,
320
292
) )
321
293
} ) ?
322
294
. into_iter ( )
0 commit comments