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

Better tag errors #109

Merged
merged 3 commits into from
Aug 24, 2018
Merged

Better tag errors #109

merged 3 commits into from
Aug 24, 2018

Conversation

wch
Copy link
Collaborator

@wch wch commented Aug 23, 2018

Prior this change, the errors from tag functions when there are extra commas are pretty useless:

> div("a", "b", )
Error in tag("div", list(...)) : argument is missing, with no default

> tags$div("a", "b", )
Error in tag("div", list(...)) : argument is missing, with no default

After this change:

> div("a", "b",)
Error in div("a", "b",  ) : argument is missing, with no default

> tags$div("a", "b",)
Error in tags$div("a", "b",  ) : argument is missing, with no default

This PR also:

  • Programmatically generates the tag functions instead of embedding a literal string in each one.
  • Simplifies the directly-exported tag functions (like div) by removing the wrapper function.

wch added 3 commits August 23, 2018 16:41
Previously, the error message would look like this:
> tags$a(1,2,)
Error in tag("a", list(...)) : argument is missing, with no default

After this change:
> tags$a(1,2,)
Error in tags$a(1, 2, ) : argument is missing, with no default
@wch
Copy link
Collaborator Author

wch commented Aug 23, 2018

The change that improves the error message is just that list(...) is evaluated before being passed to the tag() function. To illustrate:

# Old version
f <- function(...) {
  tag("div", list(...))
}

f(1, 2, )
# Error in tag("div", list(...)) : argument is missing, with no default


# New version
g <- function(...) {
  contents <- list(...)
  tag("div", contents)
}

g(1, 2, )
# Error in g(1, 2, ) : argument is missing, with no default

@jcheng5 jcheng5 self-requested a review August 24, 2018 17:25
@wch wch merged commit fe260c5 into rstudio:master Aug 24, 2018
@wch wch deleted the better-tag-errors branch August 24, 2018 17:56
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.

1 participant