Public-Health-Scotland / phsmethods

An R package to standardise methods used in Public Health Scotland (https://public-health-scotland.github.io/phsmethods/)
https://public-health-scotland.github.io/phsmethods/
54 stars 13 forks source link

Make error messages more informative #86

Closed Moohan closed 1 year ago

Moohan commented 1 year ago

I found that when start and end dates are both in wrong class, the message will only mention the start - can we have error messages mention both are in wrong class?

_Originally posted by @Tina815 in https://github.com/Public-Health-Scotland/phsmethods/pull/85#discussion_r968554013_

In the functions age_calculate and dob_from_chi (and possibly some others) there is a check near the top which makes sure that the submitted parameters are the correct class/type.

Some parameters are intuitively paired (e.g. min_date and max_date in dob_from_chi). It would be good if the error message could check both of them and then report if either or both of them are the wrong class. Currently it checks one then if that is the wrong class it will error and report that, not checking the second one.