Skip to content

Commit 58094a0

Browse files
committed
processx can return different error than the one from error_on_status
1 parent 9bc8e29 commit 58094a0

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

R/quarto.R

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -140,27 +140,35 @@ quarto_run <- function(
140140
)
141141
},
142142
error = function(e) {
143-
msg <- c(x = "Error running quarto cli.")
144-
# if there is an error message from quarto CLI, add it to the message
145-
if (e$stderr != "") {
146-
quarto_error_msg <- xfun::split_lines(e$stderr)
147-
names(quarto_error_msg) <- rep(" ", length(quarto_error_msg))
148-
msg <- c(
149-
msg,
150-
" " = paste0(rep("-", nchar(msg)), collapse = ""),
151-
quarto_error_msg
143+
if (!inherits(e, "system_command_status_error")) {
144+
cli::cli_abort(
145+
c("!" = "Error running quarto CLI from R."),
146+
call = .call,
147+
parent = e
152148
)
153-
}
149+
} else {
150+
msg <- c(x = "Error returned by quarto CLI.")
151+
# if there is an error message from quarto CLI, add it to the message
152+
if (e$stderr != "") {
153+
quarto_error_msg <- xfun::split_lines(e$stderr)
154+
names(quarto_error_msg) <- rep(" ", length(quarto_error_msg))
155+
msg <- c(
156+
msg,
157+
" " = paste0(rep("-", nchar(msg)), collapse = ""),
158+
quarto_error_msg
159+
)
160+
}
154161

155-
# if `--quiet` has been set, quarto CLI won't report any error (e$stderr will be empty)
156-
# So remind user to run without `--quiet` to see the full error message
157-
if (cli_arg_quiet() %in% args)
158-
msg <- c(
159-
msg,
160-
"i" = "Rerun with `quiet = FALSE` to see the full error message."
161-
)
162+
# if `--quiet` has been set, quarto CLI won't report any error (e$stderr will be empty)
163+
# So remind user to run without `--quiet` to see the full error message
164+
if (cli_arg_quiet() %in% args)
165+
msg <- c(
166+
msg,
167+
"i" = "Rerun with `quiet = FALSE` to see the full error message."
168+
)
162169

163-
cli::cli_abort(msg, call = .call, parent = e)
170+
cli::cli_abort(msg, call = .call, parent = e)
171+
}
164172
}
165173
)
166174
invisible(res)

tests/testthat/_snaps/quarto.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
quarto_run(c("rend", "--quiet"))
55
Condition
66
Error:
7-
x Error running quarto cli.
7+
x Error returned by quarto CLI.
88
i Rerun with `quiet = FALSE` to see the full error message.
99
Caused by error:
1010
! System command 'quarto' failed
@@ -15,8 +15,8 @@
1515
quarto_inspect()
1616
Condition
1717
Error in `quarto_inspect()`:
18-
x Error running quarto cli.
19-
-------------------------
18+
x Error returned by quarto CLI.
19+
-----------------------------
2020
ERROR: Book chapter 'intro.qmd' not found
2121
2222
Stack trace:

0 commit comments

Comments
 (0)