Produces a consistently formatted error message and stops execution.
Intended for use inside custom validation steps created with
require_custom(), so they produce the same structured errors as built-in
steps.
Usage
fail(path, message, found = NULL, at = NULL)
Arguments
- path
the full path (e.g. "x" or "newdata$x2").
- message
the specific failure message.
- found
optional value to show on a Found: line.
- at
optional integer positions to show on an At: line.
Details
Format: path: message, with optional Found: and At: lines.
Examples
if (FALSE) { # \dontrun{
fail("x", "must be positive", found = -3, at = 2L)
# Error: x: must be positive
# Found: -3
# At: 2
} # }