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

Pass calls for improved error messages #1340

Merged
merged 23 commits into from
Oct 18, 2022

Conversation

mgirlich
Copy link
Contributor

@mgirlich mgirlich commented Apr 1, 2022

Pass call to abort() and some vctrs functions for nicer error messages.
Fixes #1313.

@DavisVaughan
Copy link
Member

I'll look at these in some detail next week, thanks @mgirlich

@hadley
Copy link
Member

hadley commented Sep 29, 2022

Let's wait a week or two for vctrs and tidyselect to be out, and then I'll finish off.

#Conflicts:
#	DESCRIPTION
#	R/rectangle.R
#	tests/testthat/_snaps/nest.md
#	tests/testthat/_snaps/rectangle.md
@hadley hadley requested a review from DavisVaughan October 12, 2022 13:58
@hadley
Copy link
Member

hadley commented Oct 12, 2022

I think this should be good for review. I worked through all the snapshot files so while there are probably more places that need updates, this feels like a good place to start.

Copy link
Member

@DavisVaughan DavisVaughan left a comment

Choose a reason for hiding this comment

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

Looks really good! 90% of these comments are marking requests for call -> error_call updates based on some emerging conventions

R/expand.R Outdated Show resolved Hide resolved
R/chop.R Outdated
df_unchop <- function(x, ..., ptype = NULL, keep_empty = FALSE) {
df_unchop <- function(x, ..., ptype = NULL, keep_empty = FALSE, call = caller_env()) {
Copy link
Member

Choose a reason for hiding this comment

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

Our emerging convention when passing error calls through as arguments seems to be:

  • Name them call and arg when the function's main purpose is for some kind of input checking, i.e. vec_assert(), check_*() functions, abort(), etc.

  • Name them error_call and error_arg otherwise.

Since df_unchop()'s main purpose is unchopping, it should use error_call. The rest of the PR probably needs a pass to do this updating too. I'll try and mark them as I see them.

We have started doing this in vctrs, tidyselect, internally in dplyr, and I've done it in ivs, so probably best to take the time to be consistent here since call improvements is what this PR is all about.

Copy link
Member

Choose a reason for hiding this comment

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

FWIW I don't like this convention because it means there are 4 names it could be: call, .call, error_call, or .error_call. I'd prefer to use error_call everywhere.

Copy link
Member

Choose a reason for hiding this comment

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

This means we need to rename a lot of already exported functions? Isn't it a bit late to change this now?

By the way I don't consider a dotted variant to represent a different name. I see it as different syntax for the same name.

Copy link
Member

Choose a reason for hiding this comment

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

Right, I don't think of them as different names either, but pragmatically you have to remember which of 4 options it is.

Copy link
Member

Choose a reason for hiding this comment

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

Only in the terminal right? In IDEs you immediately see if you have a function that requires dotted arguments. It also shows you whether you need call or error_call.

R/chop.R Outdated Show resolved Hide resolved
R/extract.R Outdated Show resolved Hide resolved
R/hoist.R Show resolved Hide resolved
R/unnest-longer.R Outdated Show resolved Hide resolved
R/unnest-longer.R Outdated Show resolved Hide resolved
R/unnest-wider.R Outdated Show resolved Hide resolved
R/unnest-wider.R Outdated Show resolved Hide resolved
R/extract.R Outdated Show resolved Hide resolved
@hadley hadley merged commit 93a5235 into tidyverse:main Oct 18, 2022
@mgirlich mgirlich deleted the improved-error-messages branch January 2, 2023 08:40
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.

Pass error call information through to abort()
4 participants