Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quarto documents with rlang errors throw badly #225

Closed
pawelru opened this issue Oct 3, 2024 · 4 comments · Fixed by #226
Closed

quarto documents with rlang errors throw badly #225

pawelru opened this issue Oct 3, 2024 · 4 comments · Fixed by #226

Comments

@pawelru
Copy link

pawelru commented Oct 3, 2024

file _quarto.yaml:

project:
  type: website
  title: "test"

file test.qmd:

---
title: Test
---

Hello world!

```{r}
rlang::abort("oh no!")
```

Output:

❯ quarto render

processing file: test.qmd
1/3                  
2/3 [unnamed-chunk-1]
Error in `!continue`:
! invalid argument type
Backtrace:
  1. global .main()
  2. execute(...)
  3. rmarkdown::render(...)
  4. knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
  5. knitr:::process_file(text, output)
     ...
  9. knitr:::call_block(x)
 10. knitr:::block_exec(params)
 11. knitr:::eng_r(options)
 14. knitr (local) evaluate(...)
 15. evaluate::evaluate(...)

Quitting from lines 8-9 [unnamed-chunk-1] (test.qmd)
Execution halted

The expected result is as when converted to stop():

❯ quarto render

processing file: test.qmd
1/3                  
2/3 [unnamed-chunk-1]
Error:
! oh no!
Backtrace:
  1. global .main()
  2. execute(...)
  3. rmarkdown::render(...)
  4. knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
  5. knitr:::process_file(text, output)
     ...
 16. base::withRestarts(...)
 17. base (local) withRestartList(expr, restarts)
 18. base (local) withOneRestart(withRestartList(expr, restarts[-nr]), restarts[[nr]])
 19. base (local) docall(restart$handler, restartArgs)
 21. evaluate (local) fun(base::quote(`<smplErrr>`))

Quitting from lines 8-9 [unnamed-chunk-1] (test.qmd)
Execution halted
@hadley
Copy link
Member

hadley commented Oct 3, 2024

Duplicate of yihui/knitr#2366

@hadley hadley marked this as a duplicate of yihui/knitr#2366 Oct 3, 2024
@eternal-flame-AD
Copy link

I am the author of that issue, it looks like there is a bug here in introduced by #b834959 here:

b834959#diff-518dd3a35abbeadcd80541ab2ee49daa55dbd86f84cac0a083168e022073868cR155

If we go to the eval_error code path, there is no handler for it to return from and it will return NULL, which later in the if (!continue) will become a stop.

Calling handlers are established by withCallingHandlers. If a condition is signaled and the applicable handler is a calling handler, then the handler is called by signalCondition in the context where the condition was signaled but with the available handlers restricted to those below the handler called in the handler stack. If the handler returns, then the next handler is tried; once the last handler has been tried, signalCondition returns NULL.

CC: @yihui

hadley added a commit that referenced this issue Oct 9, 2024
Fixes #225

I can't remember exactly why this comes up, but clearly in some circumstances rethrowing the error doesn't trigger immediate termination. This shouldn't have widespread effects.
hadley added a commit that referenced this issue Oct 9, 2024
Fixes #225

I can't remember exactly why this comes up, but clearly in some circumstances rethrowing the error doesn't trigger immediate termination. This shouldn't have widespread effects.
@hadley hadley reopened this Oct 9, 2024
@hadley
Copy link
Member

hadley commented Oct 10, 2024

Ok, fairly confident that this is better as of 33c1286

@hadley hadley closed this as completed Oct 10, 2024
@pawelru
Copy link
Author

pawelru commented Oct 10, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants