[R-pkg-devel] Testing for a Specific R Error
bill at denney.ws
Sat Dec 2 14:38:19 CET 2017
I got a message last night that some of the tests in the PKNCA package do not follow best practices. ("Do not test the exact format of R messages (from R itself or from other packages): They change, and they can be translated.") Specifically, I test to ensure that an error is generated when a class cannot be coerced into a data.frame: https://cran.r-project.org/web/checks/check_results_PKNCA.html
I want to ensure that I'm getting an error that the variable cannot be coerced into a data.frame.
What is the best practice to ensure that I'm getting a specific R error (about coercion) without testing the formatting of the error text?
The only solution that immediately occurs to me is to wrap the coercion in a tryCatch and give my own error. But, then were the R error translated, the users of my package would lose the benefit of translation.
More information about the R-package-devel