Skip to content
Back to formatted view

Raw Message

Message-ID: <167ADC58-3244-4A1D-9263-22F977478D99@denney.ws>
Date: 2017-12-02T13:38:19Z
From: Bill Denney
Subject: [R-pkg-devel] Testing for a Specific R Error

Hi,

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.

Thanks,

Bill