Skip to content

Bad error message when threshold values are missing #151

@selkamand

Description

@selkamand

When a missing value (NaN) is given to the 'length' argument of assert_length we give a very obscure error message:

library(assertions)
#> Warning: package 'assertions' was built under R version 4.4.1
assert_length(1:3, length = NaN)
#> Error in if (!is_whole_number(length)) return("'length' must be a whole number"): missing value where TRUE/FALSE needed

Created on 2026-02-11 with reprex v2.1.1

There are lots of functions that have this issue. assert_greater_than fails when minimum is NaN with bad error message.

Part of this is that helpers like is_whole_number returns missing values when values are missing when they should return False. We should also check these sorts of arguments earlier and explicitly provide informative errors when they are missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions