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

Error for incorrect sxp expand argument does not print list of acceptable values #66

Closed
samrickman opened this issue Oct 18, 2022 · 0 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@samrickman
Copy link
Contributor

Here is a simple example, calling lobstr::sxp() on a numeric vector:

lobstr::sxp(1:5, expand = "numeric")

Output:

Error in `lobstr::sxp()`:
! `expand` must contain only values from
Run `rlang::last_error()` to see where the error occurred.

It looks to me like this is caused by the way the error message is called line 58 of sxp.R.

  opts <- c("character", "altrep", "environment", "call", "bytecode")
  if (any(!expand %in% opts)) {
    abort("`expand` must contain only values from ", paste("'", opts, "'", collapse = ","))
  }

This would work with message() where the first argument is ..., but rlang::abort() expects the first argument to be the message.

After I typed this out, I thought I might as well just fork the repo and amend the error message. I have done this. I will link to this issue in the PR.

I have not added a test as it seemed like overkill but when I run the same code it now produces:

Error in `lobstr::sxp()`:
! `expand` must contain only values from: 'character', 'altrep', 'environment', 'call', 'bytecode'
Run `rlang::last_error()` to see where the error occurred.

This is my first time contributing to a package so I hope it was helpful - if not let me know how it could've been more useful.

@hadley hadley added the bug an unexpected problem or unintended behavior label Oct 30, 2023
@hadley hadley closed this as completed in 9ee1481 Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants