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

More context for errors #327

Closed
hadley opened this issue Oct 18, 2022 · 5 comments
Closed

More context for errors #327

hadley opened this issue Oct 18, 2022 · 5 comments

Comments

@hadley
Copy link
Member

hadley commented Oct 18, 2022

e.g.

pivot_longer(df, c(z = y))
#> Error in `build_longer_spec()`:
#> ! Can't rename variables in this context.

Maybe just needs an error_arg?

@lionel-
Copy link
Member

lionel- commented Oct 18, 2022

hmm yes, and also pass the error call?

@hadley
Copy link
Member Author

hadley commented Oct 18, 2022

Error call is already there (build_longer_spec() is an exported tidyr function so I didn't override the call).

@lionel-
Copy link
Member

lionel- commented Oct 19, 2022

Ah in this case I think the error would be more informative for end users if you passed the call to build_longer_spec(). I think we can conceive of it as a backend function that takes error_call = current_env() (instead of caller_env()) so that callers may borrow its errors but it's still producing the correct call when called directly.

@hadley
Copy link
Member Author

hadley commented Oct 19, 2022

I think that's probably a good idea. We should probably talk through (and write up) exactly when it's appropriate for a function to take an error_call argument.

@lionel-
Copy link
Member

lionel- commented Oct 25, 2024

@olivroy contributed support for this in #350 and #359

@lionel- lionel- closed this as completed Oct 25, 2024
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

No branches or pull requests

2 participants