diff --git a/R/build-articles.R b/R/build-articles.R index 2c7cea7bf..591fe4da7 100644 --- a/R/build-articles.R +++ b/R/build-articles.R @@ -182,14 +182,14 @@ build_articles <- function(pkg = ".", cli::cli_rule("Building articles") build_articles_index(pkg) - purrr::walk( + unwrap_purrr_error(purrr::walk( pkg$vignettes$name, build_article, pkg = pkg, lazy = lazy, seed = seed, quiet = quiet - ) + )) preview_site(pkg, "articles", preview = preview) } @@ -297,7 +297,8 @@ build_article <- function(name, output_options = options, seed = seed, new_process = new_process, - quiet = quiet + quiet = quiet, + call = quote(build_article()) ) } diff --git a/R/rmarkdown.R b/R/rmarkdown.R index fc22fc66d..d8641d986 100644 --- a/R/rmarkdown.R +++ b/R/rmarkdown.R @@ -36,11 +36,11 @@ render_rmarkdown <- function(pkg, input, output, ..., seed = NULL, copy_images = path <- withCallingHandlers( callr::r_safe(rmarkdown_render_with_seed, args = args, show = !quiet), error = function(cnd) { - lines <- strsplit(cnd$stderr, "\r?\n")[[1]] + lines <- strsplit(gsub("^\r?\n", "", cnd$stderr), "\r?\n")[[1]] cli::cli_abort( c( - x = "Failed to render RMarkdown document.", - set_names(lines, " ") + "!" = "Failed to render {.path {input}}.", + set_names(lines, "x") ), parent = cnd$parent %||% cnd, trace = cnd$parent$trace, diff --git a/tests/testthat/_snaps/rmarkdown.md b/tests/testthat/_snaps/rmarkdown.md index 7ed6b9cef..a6cf86de1 100644 --- a/tests/testthat/_snaps/rmarkdown.md +++ b/tests/testthat/_snaps/rmarkdown.md @@ -14,9 +14,9 @@ Reading assets/pandoc-fail.Rmd Condition Error: - x Failed to render RMarkdown document. - [WARNING] Could not fetch resource path-to-image.png - Failing because there were warnings. + ! Failed to render 'assets/pandoc-fail.Rmd'. + x [WARNING] Could not fetch resource path-to-image.png + x Failing because there were warnings. Caused by error: ! pandoc document conversion failed with error 3 @@ -30,9 +30,8 @@ Output Error: - x Failed to render RMarkdown document. - - Quitting from lines 6-13 [unnamed-chunk-1] (r-fail.Rmd) + ! Failed to render 'assets/r-fail.Rmd'. + x Quitting from lines 6-13 [unnamed-chunk-1] (r-fail.Rmd) Caused by error: ! Error! ---