```{r}
options(
  rlang_backtrace_on_error_report = "full"
)

f <- function(do = stop) g(do)
g <- function(do) h(do)
h <- function(do) do("foo")
```

```{r, error = TRUE}
# Prior to knitr 1.51, this would report a base R error.
# After knitr 1.51, as long as a new enough rlang and evaluate are installed,
# knitr automatically global entraces all errors, so even this is entraced into
# an rlang error these days (https://github.com/yihui/knitr/pull/2388).
f()
```

```{r}
rlang::global_entrace()
```

```{r, error = TRUE}
f()
```

```{r}
f(warning)
```

```{r}
options(
  rlang_backtrace_on_warning_report = "full"
)
```

```{r}
f(warning)
```

```{r}
rlang::last_warnings()
```
