check_expr {dreamerr} | R Documentation |
Checks the evaluation of an expression
Description
This functions checks the evaluation of an expression and, if an error is thrown, captures it and integrates the captured message after a custom error message.
Usage
check_expr(expr, ..., clean, up = 0, arg_name, verbatim = FALSE)
check_expr_hook(expr, ..., clean, arg_name, verbatim = FALSE)
generate_check_expr_hook(namespace)
Arguments
expr |
An expression to be evaluated. |
... |
Character scalars. The values of If argument |
clean |
Character vector, default is missing. If provided, the function
|
up |
Integer, default is 0. It is used to construct the call in the error message.
By default the call reported is the function containing |
arg_name |
Character scalar, default is missing. Used when the expression in
|
verbatim |
Logical scalar, default is |
namespace |
Character scalar giving the namespace for which the hooks are valid. Only useful when hook functions are used in a package. |
Details
The purpose of this functions is to provide useful error messages to the user.
Functions
-
check_expr_hook()
: Ascheck_expr
but sets the error call at the level of the hooked function -
generate_check_expr_hook()
: Generates a package specificcheck_expr_hook
function
Author(s)
Laurent Berge
See Also
For general argument checking, see check_arg()
and check_set_arg()
.
Examples
test = function(x, y){
check_expr(mean(x, y), "Computing the mean didn't work:")
}