如何使 cli::cli_abort() 评估动态参数

问题描述 投票:0回答:1

在这种情况下我该如何评价

msg

f <- function(msg){
  cli::cli_abort("{msg} xxx")
}

f(msg = "{.var x}")
# Error in `f()`:
# ! {.var x} xxx
# Run `rlang::last_trace()` to see where the error occurred.
r rlang
1个回答
0
投票

我先粘:

> f <- function(msg){
+     cli::cli_abort(glue::glue("{msg} xxx"))
+ }
> f(msg = "{.var x}")
Error in `f()`:
! `x` xxx
Run `rlang::last_trace()` to see where the error occurred.
> 
© www.soinside.com 2019 - 2024. All rights reserved.