Skip to contents

[Stable]

If the provided object is a Success then the function will 'panic' and throw an error of class expect_fail_panic, with the message body set to msg.

Usage

expect_fail(x, msg, ...)

Arguments

x

The object to unwrap.

msg

The message to be included if a condition is thrown.

...

Additional optional arguments that may be used by specific methods.

Value

The error wrapped by x if a condition was not thrown as result of a Success value.

See also

expect() to unwrap the value of a Success instead, unwrap_fail() for a similar function that doesn't require msg.

Examples

Failure("Oh no I failed because of bad parameters") |>
  expect_fail("We have anticipated this failure")
#> [1] "Oh no I failed because of bad parameters"
if (FALSE) { # \dontrun{
Success(10) |> expect_fail("No Mx. Bond, I expect you to fail!")
} # }