-
Notifications
You must be signed in to change notification settings - Fork 35
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
Don't use a restart to handle stop_on_error = 2L #232
Open
cderv
wants to merge
12
commits into
main
Choose a base branch
from
fix/rlang-traceback
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
df10cdf
Don't use a restart to handle `stop_on_error = 2L`
cderv 86325bb
stop_on_error = 2L make evaluate error with output captured
cderv 24e30b6
assign result to value for cleaner snapshot
cderv 8774fe2
Add some test about render error and backtrace showing
cderv 385365f
Add missing Suggests packages
cderv 26c3a68
when testing rlang::abort(), `rlang::global_entrace()` is not needed
cderv 7bf2d80
Remove unneeded option to clarify the test case
cderv 6b31084
Add more test cases for complete coverage and example of stop_on_erro…
cderv 880b664
Use knitr and test sewed output
cderv c9d7a69
indicate to rlang top env for trimmed traceback
cderv 9b2a12b
Ensure reproducible output in snapshot
cderv c6ce2c9
Fix wrong error in test file
cderv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("!") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
2. global g() | ||
3. global h() | ||
|
||
Quitting from lines 6-10 [unnamed-chunk-1] (ressources/with-abort-error.Rmd) | ||
Execution halted |
12 changes: 12 additions & 0 deletions
12
tests/testthat/_snaps/conditions/rmd-stop-error-auto-entrace.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
27 changes: 27 additions & 0 deletions
27
tests/testthat/_snaps/conditions/rmd-stop-error-entrace-sewed.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(): ! | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
Execution halted | ||
Ran 8/8 deferred expressions |
9 changes: 9 additions & 0 deletions
9
tests/testthat/_snaps/conditions/stop-error-trace-calling-handler.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
9 changes: 9 additions & 0 deletions
9
tests/testthat/_snaps/conditions/stop-error-trace-trimmed.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
``` |
10 changes: 10 additions & 0 deletions
10
tests/testthat/ressources/with-stop-error-auto-entrace.Rmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
testthat::local_reproducible_output() | ||
handlers <- evaluate::new_output_handler( | ||
calling_handlers = list(error = function(cnd) rlang::entrace(cnd)) | ||
) | ||
options(rlang_trace_top_env = parent.frame()) | ||
evaluate::evaluate(function() { | ||
f <- function() g() | ||
g <- function() h() | ||
h <- function() stop("!") | ||
f() | ||
}, stop_on_error = 2L, output_handler = handlers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hadley doing this in evaluate allows to get trimmed traceback in
evaluate()
itself. This is related to comment at #232 (comment)See the new snapshot file without any evaluate internals.
For full context, this will be done at knitr level and so it will apply for
evaluate()
in knitr context.However, I don't know of the impact on doing that directly in evaluate.
evaluate()
is used also in other tools (like testthat) and I wonder if this could have impact.Maybe @lionel- you have some advice on setting this here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My gut feeling is that it's worth it, but I don't know if there will be other negative effects.