Skip to content

Commit

Permalink
improve rmarkdown rendering error
Browse files Browse the repository at this point in the history
  • Loading branch information
jayhesselberth committed Nov 26, 2023
1 parent 4764286 commit 84605c4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion R/build-redirects.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ build_redirects <- function(pkg = ".",

cli::cli_h2("Building redirects")
if (is.null(pkg$meta$url)) {
cli::cli_abort(sprintf("%s required to generate redirects", pkgdown_field(pkg, "url")))
cli::cli_abort("{.field {pkgdown_field('url')}} in {.file {pkgdown_config_relpath(pkg)}} required to generate redirects")
}

purrr::iwalk(
Expand Down
3 changes: 2 additions & 1 deletion R/rmarkdown.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ render_rmarkdown <- function(pkg, input, output, ..., copy_images = TRUE, quiet
error = function(cnd) {
cli::cli_abort(c(
"Failed to render RMarkdown document",
"x" = cat(gsub("\r", "", cnd$stderr, fixed = TRUE))
"x" = cnd$parent$message,
"x" = cnd$stderr
))
}
)
Expand Down
20 changes: 8 additions & 12 deletions tests/testthat/_snaps/rmarkdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,48 +23,44 @@
Code
render_rmarkdown(pkg, "assets/pandoc-fail.Rmd", "test.html", output_format = rmarkdown::html_document(
pandoc_args = "--fail-if-warnings"))
Output
[WARNING] Could not fetch resource path-to-image.png
Failing because there were warnings.
Condition
Error in `value[[3L]]()`:
! Failed to render RMarkdown document
x pandoc document conversion failed with error 3
x [WARNING] Could not fetch resource path-to-image.png Failing because there were warnings.

# render_rmarkdown yields useful error [ansi]

Code
render_rmarkdown(pkg, "assets/pandoc-fail.Rmd", "test.html", output_format = rmarkdown::html_document(
pandoc_args = "--fail-if-warnings"))
Output
[WARNING] Could not fetch resource path-to-image.png
Failing because there were warnings.
Condition
Error in `value[[3L]]()`:
! Failed to render RMarkdown document
x pandoc document conversion failed with error 3
x [WARNING] Could not fetch resource path-to-image.png Failing because there were warnings.

# render_rmarkdown yields useful error [unicode]

Code
render_rmarkdown(pkg, "assets/pandoc-fail.Rmd", "test.html", output_format = rmarkdown::html_document(
pandoc_args = "--fail-if-warnings"))
Output
[WARNING] Could not fetch resource path-to-image.png
Failing because there were warnings.
Condition
Error in `value[[3L]]()`:
! Failed to render RMarkdown document
✖ pandoc document conversion failed with error 3
✖ [WARNING] Could not fetch resource path-to-image.png Failing because there were warnings.

# render_rmarkdown yields useful error [fancy]

Code
render_rmarkdown(pkg, "assets/pandoc-fail.Rmd", "test.html", output_format = rmarkdown::html_document(
pandoc_args = "--fail-if-warnings"))
Output
[WARNING] Could not fetch resource path-to-image.png
Failing because there were warnings.
Condition
Error in `value[[3L]]()`:
! Failed to render RMarkdown document
✖ pandoc document conversion failed with error 3
✖ [WARNING] Could not fetch resource path-to-image.png Failing because there were warnings.

# render_rmarkdown styles ANSI escapes [plain]

Expand Down

0 comments on commit 84605c4

Please sign in to comment.