Skip to content

Commit

Permalink
Continue to refine build_articles() error (r-lib#2477)
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley authored and SebKrantz committed Jun 1, 2024
1 parent c470237 commit 035cc4b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
7 changes: 4 additions & 3 deletions R/build-articles.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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())
)
}

Expand Down
6 changes: 3 additions & 3 deletions R/rmarkdown.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
11 changes: 5 additions & 6 deletions tests/testthat/_snaps/rmarkdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -30,9 +30,8 @@
Output
<error/rlang_error>
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!
---
Expand Down

0 comments on commit 035cc4b

Please sign in to comment.