lobstr
lobstr copied to clipboard
Error for incorrect sxp expand argument does not print list of acceptable values
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.