If expect_error() captures an error, that is returned instead of the value.
In fact it always returns NULL on an error:
res <- expect_error(stop("foo"), "foo")
res
# NULL
res <- expect_error(stop("foo"))
res
# NULL
res <- expect_error(stop("foo"), NA)
Error: `stop("foo")` threw an error.
Message: foo
Class: simpleError/error/condition
res
# NULL
The text was updated successfully, but these errors were encountered:
From
?expect_error
:In fact it always returns NULL on an error:
The text was updated successfully, but these errors were encountered: