The behavior of functions like assert
, assert_rows
,
insist
, insist_rows
, verify
when the assertion
passes or fails is configurable via the success_fun
and error_fun
parameters, respectively.
The success_fun
parameter takes a function that takes
the data passed to the assertion function as a parameter. You can
write your own success handler function, but there are two
provided by this package:
success_continue
- just returns the data that was
passed into the assertion function
success_logical
- returns TRUE
The error_fun
parameter takes a function that takes
the data passed to the assertion function as a parameter. You can
write your own error handler function, but there are a few
provided by this package:
error_stop
- Prints a summary of the errors and
halts execution.
error_report
- Prints all the information available
about the errors in a "tidy"
data.frame
(including information
such as the name of the predicate used,
the offending value, etc...) and halts
execution.
error_append
- Attaches the errors to a special
attribute of data
and returns the data. This is chiefly
to allow assertr errors to be accumulated in a pipeline so that
all assertions can have a chance to be checked and so that all
the errors can be displayed at the end of the chain.
error_return
- Returns the raw object containing all
the errors
error_df_return
- Returns a "tidy" data.frame
containing all the errors, including informations such as
the name of the predicate used, the offending value, etc...
error_logical
- returns FALSE
just_warn
- Prints a summary of the errors but does
not halt execution, it just issues a warning.
warn_report
- Prints all the information available
about the errors but does not halt execution, it just issues a warning.
success_logical(data, ...)success_continue(data, ...)
error_stop(errors, data = NULL, warn = FALSE, ...)
just_warn(errors, data = NULL)
error_report(errors, data = NULL, warn = FALSE, ...)
warn_report(errors, data = NULL)
error_append(errors, data = NULL)
error_return(errors, data = NULL)
error_df_return(errors, data = NULL)
error_logical(errors, data = NULL, ...)
A data frame
Further arguments passed to or from other methods
A list of objects of class assertr_errors
If TRUE, assertr will issue a warning instead of an error