Improve error message for `player_id` contains NA
stecaron opened this issue · comments
I did noticed that we passing a vector of player_id
containing at least one NA
, we received this error :
Error in tidy_players_meta(players_id = unique(dt_draft$player_id), keep_id = TRUE) :
argument 'players_id' should be a vector of integers
Maybe would be helpful to receive a more descriptive error message.
I made a comprehensive review of argument assertions following your advice. It's now implemented with 1256bb5. Feel free to re-install de master
branch and test.
You can appreciate the new behaviour below:
tidy_players_meta(c(1, 8476981, NA))
## player_name player_active player_roster_status player_number player_position player_position_type player_nationality player_birth_country player_birth_stateprovince player_birth_city player_birth_date
## 1: Josh Anderson TRUE Y 17 R F CAN CAN ON Burlington 1994-05-07
## player_dead player_death_date player_inches player_pounds player_hand player_rookie player_hof player_hof_year player_nhl_100 team_abbreviation
## 1: FALSE <NA> 75 226 R FALSE FALSE NA FALSE MTL
## Warning messages:
## 1: In assert_players_id(players_id) :
## NAs were detected and dropped in the 'players_id' argument
## 2: In assert_players_id(players_id) :
## the following elements of the argument 'players_id' were dropped since not identified as valid NHL player IDs: 1
I will close the issue, please reopen if there is anything else related to assertions that could still be improve.