-
Notifications
You must be signed in to change notification settings - Fork 66
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
Update OOB errors #1737
base: main
Are you sure you want to change the base?
Update OOB errors #1737
Changes from all commits
4664f27
d78350c
5ed99f0
3002741
a1e7bbf
ad93a63
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 |
---|---|---|
|
@@ -207,8 +207,8 @@ | |
Output | ||
<error/vctrs_error_subscript_oob> | ||
Error in `my_function()`: | ||
! Can't subset elements past the end. | ||
i Location 10 doesn't exist. | ||
! Can't subset elements with `10`. | ||
x Location must be less than or equal to 2, not 10. | ||
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. Could this be one line like 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. This is slightly problematic because these errors are used for subsetting across tibble rows and cols. So it's hard to find generic formulations that work well for all cases. 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. We could say "input has 2 elements" or "input has 3 rows". This is how we currently phrase it in an additional info bullet, but I guess you're saying this information should be closer? Another difficult aspect is how to handle the case where multiple locations are not found without creating a too long line. To address this, I try to consistently mention multiple locations in their own bullet in this PR. But then it's hard to keep the length info close. |
||
i There are only 2 elements. | ||
|
||
--- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,16 +23,16 @@ | |
Output | ||
<error/vctrs_error_subscript_oob> | ||
Error in `vec_slice()`: | ||
! Can't subset elements past the end. | ||
i Location 3 doesn't exist. | ||
! Can't subset elements with `i`. | ||
x Location must be less than or equal to 2, not 3. | ||
i There are only 2 elements. | ||
Code | ||
(expect_error(vec_slice(1:2, -3L), class = "vctrs_error_subscript_oob")) | ||
Output | ||
<error/vctrs_error_subscript_oob> | ||
Error in `vec_slice()`: | ||
! Can't negate elements past the end. | ||
i Location 3 doesn't exist. | ||
! Can't negate elements with `i`. | ||
x Location must be less than or equal to 2, not 3. | ||
i There are only 2 elements. | ||
|
||
# can slice with double indices | ||
|
@@ -79,17 +79,18 @@ | |
vec_slice(c(bar = 1), "foo") | ||
Condition | ||
Error in `vec_slice()`: | ||
! Can't subset elements that don't exist. | ||
x Element `foo` doesn't exist. | ||
! Can't subset elements with `i`. | ||
x Can't find element `foo`. | ||
|
||
--- | ||
|
||
Code | ||
vec_slice(letters, c(100, 1000)) | ||
Condition | ||
Error in `vec_slice()`: | ||
! Can't subset elements past the end. | ||
i Locations 100 and 1000 don't exist. | ||
! Can't subset elements with `i`. | ||
x Locations must be less than or equal to 26. | ||
x Larger locations: 100 and 1000 | ||
i There are only 26 elements. | ||
|
||
--- | ||
|
@@ -98,8 +99,9 @@ | |
vec_slice(letters, c(1, 100:103, 2, 104:110)) | ||
Condition | ||
Error in `vec_slice()`: | ||
! Can't subset elements past the end. | ||
i Locations 100, 101, 102, ..., 109, and 110 don't exist. | ||
! Can't subset elements with `i`. | ||
x Locations must be less than or equal to 26. | ||
x Larger locations: 100, 101, 102, ..., 109, and 110 | ||
i There are only 26 elements. | ||
|
||
--- | ||
|
@@ -108,17 +110,17 @@ | |
vec_slice(set_names(letters), c("foo", "bar")) | ||
Condition | ||
Error in `vec_slice()`: | ||
! Can't subset elements that don't exist. | ||
x Elements `foo` and `bar` don't exist. | ||
! Can't subset elements with `i`. | ||
x Can't find elements `foo` and `bar`. | ||
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. This is a case where chained errors might fit better because there are multiple bullets "can't / must" bullets describing a problem at different levels. Same for the "must" cross bullet above. |
||
|
||
--- | ||
|
||
Code | ||
vec_slice(set_names(letters), toupper(letters)) | ||
Condition | ||
Error in `vec_slice()`: | ||
! Can't subset elements that don't exist. | ||
x Elements `A`, `B`, `C`, `D`, `E`, etc. don't exist. | ||
! Can't subset elements with `i`. | ||
x Can't find elements `A`, `B`, `C`, `D`, `E`, etc.. | ||
|
||
# vec_init() validates `n` | ||
|
||
|
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.
Do we really need "Can't subset elements" in these three errors?
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.
The thing is that this is this header that carries the
arg
information, if any. That will be the case when called fromselect()
and tibble's subset methods.