R: Is an error informative?

is_informative_error {testthat} | R Documentation

## Is an error informative?

### Description

`is_informative_error()` is a generic predicate that indicates whether testthat users should explicitly test for an error class. When it returns `TRUE` (the default), and `expect_error()` does not check for the class, a warning is issued during tests. You can silence the warning by implementing `is_informative_error()`.

The main use case for overriding this method is to introduce an experimental error class when you need more experience while developing an error hierarchy for your package. Override `is_informative_error()` to return `FALSE` to avoid encouraging users to depend on the experimental class in their tests.

Since testthat should be a `Suggest` dependency, methods for `is_informative_error()` should typically be lazily registered, e.g. with `vctrs::s3_register()`.

### Usage

    is_informative_error(x, ...)

### Arguments

`x` | An error object.
`...` | These dots are for future extensions and must be empty.

### Details

A few classes are hard-coded as uninformative:

- `simpleError`

- `rlang_error` unless a subclass is detected

- `Rcpp::eval_error`

- `Rcpp::exception`

[Package testthat version 2.3.2 Index]