reprex
reprex copied to clipboard
Entrace base errors?
This is a follow-up to #229 and how dev rlang always shows a backtrace on error in non-interactive sessions. It might be helpful and more consistent to entrace base errors with rlang::entrace()
. Unfortunately, simply setting options(error = rlang::entrace)
doesn't work because rmarkdown::render()
captures the errors before entrace()
has a chance to be called.
Would it be worth it to find a solution to that problem? The easiest way might be to add an option to entrace errors in rmarkdown itself.
Proof of concept at https://github.com/tidyverse/reprex/compare/fix-top-trace...add-base-entrace:
remotes::install_github("tidyverse/reprex@add-base-entrace")
When prompted, upgrade knitr and evaluate.
-
r-lib/evaluate
needs support for calling handlers: https://github.com/r-lib/evaluate/compare/master...lionel-:add-calling-handlers -
yihui/knitr
needs support for thecalling.handlers
chunk option: https://github.com/yihui/knitr/compare/master...lionel-:add-calling-handlers
We should also provide some optional way to activate this for warnings too.
options(warn = 2)
should work. But won't that create misleading reprexes if we enable it by default?
Or should we capture all warnings, with an accompanying trace?
https://github.com/r-lib/rlang/issues/714
@lionel- Has the world changed since we last discussed this? What's the best way to support entrancing base errors?
Adding entrace
as a calling handler. That's also the correct way to entrace rlang errors. Cf the weird dplyr example I've just posted in the other thread.