-
Notifications
You must be signed in to change notification settings - Fork 36
Don't use a restart to handle stop_on_error = 2L #232
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
Changes from all commits
df10cdf
86325bb
24e30b6
8774fe2
385365f
26c3a68
7bf2d80
6b31084
880b664
c9d7a69
9b2a12b
c6ce2c9
3a95542
82557b4
d7e3fa8
98ff231
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Error in `h()`: | ||
! ! | ||
Backtrace: | ||
x | ||
1. \-global f() | ||
2. \-global g() | ||
3. \-global h() | ||
4. \-rlang::abort("!") | ||
Execution halted | ||
Ran 8/8 deferred expressions |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
title: document with error | ||
--- | ||
|
||
|
||
``` r | ||
f <- function() g() | ||
g <- function() h() | ||
h <- function() rlang::abort("!") | ||
f() | ||
``` | ||
|
||
``` | ||
## Error in `h()`: | ||
## ! ! | ||
## Backtrace: | ||
## x | ||
## 1. \-evaluate (local) f() | ||
## 2. \-evaluate (local) g() | ||
## 3. \-evaluate (local) h() | ||
## 4. \-rlang::abort("!") | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
|
||
processing file: ressources/with-abort-error.Rmd | ||
Error in `h()`: | ||
! ! | ||
Backtrace: | ||
1. global f() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do we need to do to display a tree here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm surprised to see the simplified backtrace which is no longer the default in rlang. Do we have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @cderv Could you test with r-lib/rlang#1769 please? I'm hoping it helps in non-interactive sessions without adverse effects in interactive ones (calling There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regarding the two snapshot, they are "fixed" diff --git a/tests/testthat/_snaps/conditions/rmd-abort-error.txt b/tests/testthat/_snaps/conditions/rmd-abort-error.txt
index 114acb6..6b87b65 100644
--- a/tests/testthat/_snaps/conditions/rmd-abort-error.txt
+++ b/tests/testthat/_snaps/conditions/rmd-abort-error.txt
@@ -4,9 +4,11 @@ processing file: ressources/with-abort-error.Rmd
Error in `h()`:
! !
Backtrace:
- 1. global f()
- 2. global g()
- 3. global h()
+ ▆
+ 1. └─global f()
+ 2. └─global g()
+ 3. └─global h()
+ 4. └─rlang::abort("!")
Quitting from lines 6-10 [unnamed-chunk-1] (ressources/with-abort-error.Rmd)
Execution halted diff --git a/tests/testthat/_snaps/conditions/rmd-stop-error-auto-entrace.txt b/tests/testthat/_snaps/conditions/rmd-stop-error-auto-entrace.txt
index c2ea7b0..a1867ee 100644
--- a/tests/testthat/_snaps/conditions/rmd-stop-error-auto-entrace.txt
+++ b/tests/testthat/_snaps/conditions/rmd-stop-error-auto-entrace.txt
@@ -4,9 +4,10 @@ processing file: ressources/with-stop-error-auto-entrace.Rmd
Error in `h()`:
! !
Backtrace:
- 1. global f()
- 2. global g()
- 3. global h()
+ ▆
+ 1. └─global f()
+ 2. └─global g()
+ 3. └─global h()
Quitting from lines 6-10 [unnamed-chunk-1] (ressources/with-stop-error-auto-entrace.Rmd)
Execution halted I then tested manually and I think I covered most of cases. It does not seem to have adverse affect on interactive session. It looks good to merge. Maybe I'll update the snapshot once next rlang is release so that it does not prevent evaluate release. |
||
2. global g() | ||
3. global h() | ||
|
||
Quitting from lines 6-10 [unnamed-chunk-1] (ressources/with-abort-error.Rmd) | ||
Execution halted |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
|
||
processing file: ressources/with-stop-error-auto-entrace.Rmd | ||
Error in `h()`: | ||
! ! | ||
Backtrace: | ||
1. global f() | ||
2. global g() | ||
3. global h() | ||
|
||
Quitting from lines 6-10 [unnamed-chunk-1] (ressources/with-stop-error-auto-entrace.Rmd) | ||
Execution halted |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
title: document with error | ||
--- | ||
|
||
|
||
``` r | ||
rlang::global_entrace() | ||
options(rlang_backtrace_on_error_report = "full") | ||
``` | ||
|
||
|
||
``` r | ||
f <- function() g() | ||
g <- function() h() | ||
h <- function() stop("!") | ||
f() | ||
``` | ||
|
||
``` | ||
## Error in `h()`: | ||
## ! ! | ||
## Backtrace: | ||
## x | ||
## 1. \-evaluate (local) f() | ||
## 2. \-evaluate (local) g() | ||
## 3. \-evaluate (local) h() | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: document with error | ||
--- | ||
|
||
|
||
``` r | ||
f <- function() g() | ||
g <- function() h() | ||
h <- function() stop("!") | ||
f() | ||
``` | ||
|
||
``` | ||
## Error in h(): ! | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Error in h() : ! | ||
Calls: <Anonymous> ... withCallingHandlers -> withVisible -> eval -> eval -> f -> g -> h | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is the error you see when a vignette has an error, so that might suggest if we can entrace in a vignette we can get better errors? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good idea. I'll see if I can adapt knitr for this. |
||
Execution halted | ||
Ran 8/8 deferred expressions |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Error in `h()`: | ||
! ! | ||
Backtrace: | ||
x | ||
1. \-global f() | ||
2. \-global g() | ||
3. \-global h() | ||
Execution halted | ||
Ran 8/8 deferred expressions |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Error in `h()`: | ||
! ! | ||
Backtrace: | ||
x | ||
1. +-evaluate::evaluate(...) | ||
2. | +-base::withRestarts(...) | ||
3. | | \-base (local) withRestartList(expr, restarts) | ||
4. | | +-base (local) withOneRestart(withRestartList(expr, restarts[-nr]), restarts[[nr]]) | ||
5. | | | \-base (local) doWithOneRestart(return(expr), restart) | ||
6. | | \-base (local) withRestartList(expr, restarts[-nr]) | ||
7. | | \-base (local) withOneRestart(expr, restarts[[1L]]) | ||
8. | | \-base (local) doWithOneRestart(return(expr), restart) | ||
9. | +-evaluate:::with_handlers(...) | ||
10. | | +-base::eval(call) | ||
11. | | | \-base::eval(call) | ||
12. | | \-base::withCallingHandlers(...) | ||
13. | +-base::withVisible(eval(expr, envir)) | ||
14. | \-base::eval(expr, envir) | ||
15. | \-base::eval(expr, envir) | ||
16. \-global f() | ||
17. \-global g() | ||
18. \-global h() | ||
Execution halted | ||
Ran 8/8 deferred expressions |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Error in `h()`: | ||
! ! | ||
Backtrace: | ||
x | ||
1. \-global f() | ||
2. \-global g() | ||
3. \-global h() | ||
Execution halted | ||
Ran 8/8 deferred expressions |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
testthat::local_reproducible_output() | ||
evaluate::evaluate(function() { | ||
f <- function() g() | ||
g <- function() h() | ||
h <- function() rlang::abort("!") | ||
f() | ||
}, stop_on_error = 2L) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
title: document with error | ||
--- | ||
|
||
```{r} | ||
f <- function() g() | ||
g <- function() h() | ||
h <- function() rlang::abort("!") | ||
f() | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
title: document with error | ||
--- | ||
|
||
```{r} | ||
f <- function() g() | ||
g <- function() h() | ||
h <- function() stop("!") | ||
f() | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
testthat::local_reproducible_output() | ||
evaluate::evaluate(function() { | ||
f <- function() g() | ||
g <- function() h() | ||
h <- function() stop("!") | ||
f() | ||
}, stop_on_error = 2L) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: document with error | ||
--- | ||
|
||
```{r} | ||
rlang::global_entrace() | ||
options(rlang_backtrace_on_error_report = "full") | ||
``` | ||
|
||
```{r} | ||
f <- function() g() | ||
g <- function() h() | ||
h <- function() stop("!") | ||
f() | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
testthat::local_reproducible_output() | ||
handlers <- evaluate::new_output_handler( | ||
calling_handlers = list(error = function(cnd) rlang::entrace(cnd)) | ||
) | ||
library(evaluate) | ||
options(rlang_trace_top_env = rlang::pkg_env("evaluate")) | ||
evaluate(function() { | ||
f <- function() g() | ||
g <- function() h() | ||
h <- function() stop("!") | ||
f() | ||
}, stop_on_error = 2L, output_handler = handlers) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
testthat::local_reproducible_output() | ||
handlers <- evaluate::new_output_handler( | ||
calling_handlers = list(error = function(cnd) rlang::entrace(cnd)) | ||
) | ||
evaluate::evaluate(function() { | ||
f <- function() g() | ||
g <- function() h() | ||
h <- function() stop("!") | ||
f() | ||
}, stop_on_error = 2L, output_handler = handlers) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
testthat::local_reproducible_output() | ||
withCallingHandlers( | ||
error = function(cnd) rlang::entrace(cnd), | ||
evaluate::evaluate(function() { | ||
f <- function() g() | ||
g <- function() h() | ||
h <- function() stop("!") | ||
f() | ||
}, stop_on_error = 2L) | ||
) |
Uh oh!
There was an error while loading. Please reload this page.