@@ -186,19 +186,23 @@ adjust_frosting.frosting <- function(
186
186
x $ layers [[which_layer ]] <- update(x $ layers [[which_layer ]], ... )
187
187
} else {
188
188
layer_names <- map_chr(x $ layers , ~ attr(.x , " class" )[1 ])
189
+ starts_with_layer <- substr(which_layer , 1 , 6 ) == " layer_"
190
+ if (! starts_with_layer ) which_layer <- paste0(" layer_" , which_layer )
189
191
190
192
if (! (which_layer %in% layer_names )) {
191
- cli :: cli_abort(
192
- c(" `which_layer` is not in the `frosting` layer names. " ,
193
- " i" = " The layer names are {layer_names}."
194
- )
195
- )
193
+ cli :: cli_abort(c(
194
+ " `which_layer` does not appear in the available `frosting` layer names. " ,
195
+ i = " The layer names are {.val {layer_names}}."
196
+ ))
196
197
}
197
198
which_layer_idx <- which(layer_names == which_layer )
198
199
if (length(which_layer_idx ) == 1 ) {
199
200
x $ layers [[which_layer_idx ]] <- update(x $ layers [[which_layer_idx ]], ... )
200
201
} else {
201
- cli :: cli_abort(" `which_layer` is not unique. Matches layers: {which_layer_idx}." )
202
+ cli :: cli_abort(c(
203
+ " `which_layer` is not unique. Matches layers: {.val {which_layer_idx}}." ,
204
+ i = " Please use the layer number instead for precise alterations."
205
+ ))
202
206
}
203
207
}
204
208
x
@@ -212,7 +216,7 @@ add_postprocessor <- function(x, postprocessor, ..., call = caller_env()) {
212
216
if (is_frosting(postprocessor )) {
213
217
return (add_frosting(x , postprocessor ))
214
218
}
215
- rlang :: abort (" `postprocessor` must be a frosting object." , call = call )
219
+ cli :: cli_abort (" `postprocessor` must be a frosting object." , call = call )
216
220
}
217
221
218
222
is_frosting <- function (x ) {
@@ -223,8 +227,8 @@ is_frosting <- function(x) {
223
227
validate_frosting <- function (x , ... , arg = " `x`" , call = caller_env()) {
224
228
rlang :: check_dots_empty()
225
229
if (! is_frosting(x )) {
226
- glubort (
227
- " {arg} must be a frosting postprocessor, not a {class(x)[[1]]}." ,
230
+ cli :: cli_abort (
231
+ " {arg} must be a frosting postprocessor, not a {.cls { class(x)[[1]]} }." ,
228
232
.call = call
229
233
)
230
234
}
@@ -283,10 +287,9 @@ new_frosting <- function() {
283
287
# ' p
284
288
frosting <- function (layers = NULL , requirements = NULL ) {
285
289
if (! is_null(layers ) || ! is_null(requirements )) {
286
- rlang :: abort(c(
287
- " Currently, no arguments to `frosting()` are allowed" ,
288
- " to be non-null."
289
- ))
290
+ cli :: cli_abort(
291
+ " Currently, no arguments to `frosting()` are allowed to be non-null."
292
+ )
290
293
}
291
294
out <- new_frosting()
292
295
}
@@ -305,7 +308,8 @@ extract_frosting <- function(x, ...) {
305
308
306
309
# ' @export
307
310
extract_frosting.default <- function (x , ... ) {
308
- abort(c(" Frosting is only available for epi_workflows currently." ,
311
+ cli :: cli_abort(c(
312
+ " Frosting is only available for epi_workflows currently." ,
309
313
i = " Can you use `epi_workflow()` instead of `workflow()`?"
310
314
))
311
315
invisible (x )
@@ -339,7 +343,8 @@ apply_frosting <- function(workflow, ...) {
339
343
# ' @export
340
344
apply_frosting.default <- function (workflow , components , ... ) {
341
345
if (has_postprocessor(workflow )) {
342
- abort(c(" Postprocessing is only available for epi_workflows currently." ,
346
+ cli :: cli_abort(c(
347
+ " Postprocessing is only available for epi_workflows currently." ,
343
348
i = " Can you use `epi_workflow()` instead of `workflow()`?"
344
349
))
345
350
}
@@ -367,8 +372,8 @@ apply_frosting.epi_workflow <-
367
372
}
368
373
369
374
if (! has_postprocessor_frosting(workflow )) {
370
- rlang :: warn (c(
371
- " Only postprocessors of class frosting are allowed." ,
375
+ cli :: cli_warn (c(
376
+ " Only postprocessors of class {.cls frosting} are allowed." ,
372
377
" Returning unpostprocessed predictions."
373
378
))
374
379
components $ predictions <- predict(
0 commit comments