Skip to content

Commit

Permalink
Don't show backtrace (#449)
Browse files Browse the repository at this point in the history
* Don't show backtrace

Fixes #448. Closes #433. Closes #230.

* Re-document()

---------

Co-authored-by: Jenny Bryan <[email protected]>
  • Loading branch information
hadley and jennybc authored Nov 15, 2023
1 parent ce5c62c commit ad02922
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 21 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# reprex (development version)

* `reprex()` no longer includes the full traceback by default, as this is
only useful in relatively rare situations, and otherwise adds a bunch
of clutter (#448).

The unexported `prex_*()` functions protect the current session from option changes coming from reprex's own machinery, such as disabling color (#427).

# reprex 2.0.2
Expand Down
14 changes: 4 additions & 10 deletions R/reprex.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,10 @@
#'
#' @section Error backtraces:
#'
#' reprex sets the rlang option `rlang_backtrace_on_error_report = "full"`.
#' Combined with the knitr option `error = TRUE`, this means rlang errors are
#' displayed with a full backtrace. This basically eliminates the need to call
#' [rlang::last_error()] or [rlang::last_trace()] explicitly, although these
#' functions can be used in a reprex.
#'

#' Insert a line containing the special comment `#'` in between the
#' error-causing code and the `last_error()` or `last_trace()` call, to fulfill
#' the requirement of being in separate chunks:
#' To use [rlang::last_error()] or [rlang::last_trace()] within a reprex,
#' you must place them in a different "chunk" to the code that generates an
#' error. The easiest way to do is to insert a line containing the special
#' comment `#'` after error-causing code:

#' ``` r
#' f <- function() rlang::abort('foo')
Expand Down
1 change: 0 additions & 1 deletion R/reprex_document.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ reprex_opts <- function(venue = "gh") {
```{{r reprex-options, include = FALSE}}
options(
keep.source = TRUE,
rlang_backtrace_on_error_report = "full",
crayon.enabled = FALSE,
reprex.current_venue = "{venue}"
)
Expand Down
1 change: 0 additions & 1 deletion R/reprex_render.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ reprex_render_impl <- function(input,
# should be kept in sync with what reprex_opts() sets
opts_to_safeguard <- options(
"keep.source",
"rlang_backtrace_on_error_report",
"crayon.enabled"
)
withr::defer(options(opts_to_safeguard))
Expand Down
13 changes: 4 additions & 9 deletions man/reprex.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ad02922

Please sign in to comment.