Skip to content
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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Update OOB errors #1737

wants to merge 6 commits into from

Conversation

lionel-
Copy link
Member

@lionel- lionel- commented Oct 21, 2022

  • Use standard subscript error header in OOB errors.
  • Use actual vs expected phrasing.
  • Merge OOB and non-consecutive OOB errors. Instead of a specific error, just mention in an info bullet that consecutive extension is allowed.
  • When multiple locations are problematic, mention them in their own cross bullet.

! 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`.
Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Member

@hadley hadley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is an improvement, but it feels like we can still do even better, so I'd like to push this off until the next release so we can spend more time on it, and do it once.

@@ -22,24 +22,24 @@
Output
<error/vctrs_error_subscript_oob>
Error in `vec_slice()`:
! Can't subset elements that don't exist.
x Element `foo` doesn't exist.
! Can't subset elements.
Copy link
Member

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?

Copy link
Member Author

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 from select() and tibble's subset methods.

! 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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be one line like Can't find location 10; input is length 2?

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

@lionel- lionel- changed the base branch from error-update-header to main October 21, 2022 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants