Skip to content

Commit

Permalink
Add guidance to rerun with quiet = FALSE when the full error messag…
Browse files Browse the repository at this point in the history
…e is not shown

closes #126
  • Loading branch information
cderv committed Jan 23, 2024
1 parent 8a0bcb3 commit 5a1aae2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# quarto (development version)

- Error message now advice to re-run with `quiet = FALSE` as `quarto_render(quiet = TRUE)` will make `quarto render` run in quiet mode (thanks, @gadenbuie, #126, @wlandau, #16).

- **rsconnect** R package dependency has been moved to Suggest to reduce this package's overall number of dependencies. **rsconnect** package is only required for publishing using `quarto_publish_*()` functions. If not installed, users will be prompted to install (when in interactive mode).

- Add `quarto_add_extension()` and `quarto_use_template()` to deal with Quarto extensions for a Quarto project. (thanks, @mcanouil, #45, @remlapmot, #42).
Expand Down
7 changes: 6 additions & 1 deletion R/quarto.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ quarto_run <- function(args = character(), quarto_bin = find_quarto(), echo = FA
res <- tryCatch({
processx::run(quarto_bin, args = args, echo = FALSE, error_on_status = TRUE, echo_cmd = echo_cmd, ...)
},
error = function(e) rlang::abort(c("Error running quarto cli:", x = e$stderr), call = .call, parent = e)
error = function(e) {
msg <- c("Error running quarto cli:")
if (nzchar(e$stderr)) msg <- c(msg, "x" = e$stderr)
if ("--quiet" %in% args) msg <- c(msg, "i" = "Rerun with `quiet = FALSE` to see the full error message.")
rlang::abort(msg, call = .call, parent = e)
}
)
invisible(res)
}
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/_snaps/quarto.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# quarto_run gives guidance in error

Code
quarto_run(c("rend", "--quiet"))
Condition
Error:
! Error running quarto cli:
i Rerun with `quiet = FALSE` to see the full error message.
Caused by error:
! System command 'quarto.exe' failed

5 changes: 5 additions & 0 deletions tests/testthat/test-quarto.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@ test_that("quarto_version returns a numeric version", {
skip_if_no_quarto()
expect_s3_class(quarto_version(), "numeric_version")
})

test_that("quarto_run gives guidance in error", {
skip_if_no_quarto()
expect_snapshot(quarto_run(c("rend", "--quiet")), error = TRUE)
})

0 comments on commit 5a1aae2

Please sign in to comment.