reprex icon indicating copy to clipboard operation
reprex copied to clipboard

Entrace base errors?

Open lionel- opened this issue 5 years ago • 7 comments

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.

lionel- avatar Jan 03 '19 13:01 lionel-

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 the calling.handlers chunk option: https://github.com/yihui/knitr/compare/master...lionel-:add-calling-handlers

lionel- avatar Jan 05 '19 15:01 lionel-

We should also provide some optional way to activate this for warnings too.

hadley avatar Jan 08 '19 16:01 hadley

options(warn = 2) should work. But won't that create misleading reprexes if we enable it by default?

lionel- avatar Jan 08 '19 16:01 lionel-

Or should we capture all warnings, with an accompanying trace?

lionel- avatar Jan 08 '19 16:01 lionel-

https://github.com/r-lib/rlang/issues/714

lionel- avatar Jan 08 '19 16:01 lionel-

@lionel- Has the world changed since we last discussed this? What's the best way to support entrancing base errors?

jennybc avatar Aug 20 '20 19:08 jennybc

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.

lionel- avatar Aug 21 '20 08:08 lionel-