Skip to content

Commit

Permalink
Don't try to print message afterward
Browse files Browse the repository at this point in the history
This means we won't rethrow the error, just complete the message if quiet is opt in
  • Loading branch information
cderv committed Feb 1, 2024
1 parent 378aa59 commit b1733d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
12 changes: 3 additions & 9 deletions R/quarto.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,14 @@ quarto_version <- function() {
#' @importFrom processx run
quarto_run <- function(args = character(), quarto_bin = find_quarto(), echo = FALSE, echo_cmd = getOption("quarto.echo_cmd", FALSE), ..., .call = rlang::caller_env()) {
res <- tryCatch({
processx::run(quarto_bin, args = args, echo = FALSE, error_on_status = TRUE, echo_cmd = echo_cmd, ...)
processx::run(quarto_bin, args = args, echo = echo, error_on_status = TRUE, echo_cmd = echo_cmd, ...)
},
error = function(e) {
msg <- c("Error running quarto cli:")
if (nzchar(e$stderr)) msg <- c(msg, "x" = e$stderr)
msg <- c(x = "Error running quarto cli.")
if (cli_arg_quiet() %in% args) msg <- c(msg, "i" = "Rerun with `quiet = FALSE` to see the full error message.")
rlang::abort(msg, call = .call, parent = e)
cli::cli_abort(msg, call = .call, parent = e)
}
)
# quarto outputs any message into stderr as stdout is reserved
# for regular rendered output (that we don't support in this package yet)
if (echo && nzchar(res$stderr)) {
cli::cat_line(res$stderr)
}
invisible(res)
}

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/quarto.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
quarto_run(c("rend", "--quiet"))
Condition
Error:
! Error running quarto cli:
x Error running quarto cli.
i Rerun with `quiet = FALSE` to see the full error message.
Caused by error:
! System command 'quarto' failed
Expand Down

0 comments on commit b1733d7

Please sign in to comment.