@@ -148,7 +148,16 @@ quarto_run <- function(
148148 env = custom_env ,
149149 ...
150150 ),
151- error = function (e ) wrap_quarto_error(e , args , .call = .call )
151+ system_command_status_error = function (e ) {
152+ wrap_quarto_error(e , args , .call = .call )
153+ },
154+ error = function (e ) {
155+ cli :: cli_abort(
156+ c(" !" = " Error running quarto CLI from R." ),
157+ call = .call ,
158+ parent = e
159+ )
160+ }
152161 )
153162
154163 invisible (res )
@@ -308,38 +317,30 @@ quarto_binary_sitrep <- function(verbose = TRUE, debug = FALSE) {
308317
309318
310319wrap_quarto_error <- function (cnd , args , .call = rlang :: caller_env()) {
311- if (! inherits(cnd , " system_command_status_error" )) {
312- cli :: cli_abort(
313- c(" !" = " Error running quarto CLI from R." ),
314- call = .call ,
315- parent = cnd
320+ msg <- c(x = " Error returned by quarto CLI." )
321+ # if there is an error message from quarto CLI, add it to the message
322+ if (cnd $ stderr != " " ) {
323+ quarto_error_msg <- xfun :: split_lines(cnd $ stderr )
324+ names(quarto_error_msg ) <- rep(" " , length(quarto_error_msg ))
325+ msg <- c(
326+ msg ,
327+ " " = paste0(rep(" -" , nchar(msg )), collapse = " " ),
328+ quarto_error_msg
316329 )
317- } else {
318- msg <- c(x = " Error returned by quarto CLI." )
319- # if there is an error message from quarto CLI, add it to the message
320- if (cnd $ stderr != " " ) {
321- quarto_error_msg <- xfun :: split_lines(cnd $ stderr )
322- names(quarto_error_msg ) <- rep(" " , length(quarto_error_msg ))
323- msg <- c(
324- msg ,
325- " " = paste0(rep(" -" , nchar(msg )), collapse = " " ),
326- quarto_error_msg
327- )
328- }
329-
330- # if `--quiet` has been set, quarto CLI won't report any error (cnd$stderr will be empty)
331- # So remind user to run without `--quiet` to see the full error message
332- if (cli_arg_quiet() %in% args ) {
333- msg <- c(
334- msg ,
335- " i" = " Rerun with `quiet = FALSE` to see the full error message."
336- )
337- }
330+ }
338331
339- cli :: cli_abort(
332+ # if `--quiet` has been set, quarto CLI won't report any error (cnd$stderr will be empty)
333+ # So remind user to run without `--quiet` to see the full error message
334+ if (cli_arg_quiet() %in% args ) {
335+ msg <- c(
340336 msg ,
341- call = .call ,
342- parent = cnd ,
337+ " i" = " Rerun with `quiet = FALSE` to see the full error message."
343338 )
344339 }
340+
341+ cli :: cli_abort(
342+ msg ,
343+ call = .call ,
344+ parent = cnd ,
345+ )
345346}
0 commit comments