Skip to content

Commit

Permalink
add input checks to run_safely()
Browse files Browse the repository at this point in the history
  • Loading branch information
nikosbosse committed Mar 28, 2024
1 parent 5ca82e1 commit 2eee97a
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#' @param ... Arguments to pass to `fun`.
#' @param fun A function to execute.
#' @importFrom cli cli_warn
#' @importFrom checkmate assert_function
#' @return The result of `fun` or `NULL` if `fun` errors
#' @export
#' @keywords scoring
Expand All @@ -24,6 +25,7 @@
#' run_safely(fun = f)
#' run_safely(y = 3, fun = f)
run_safely <- function(..., fun) {
assert_function(fun)
args <- list(...)
# Check if the function accepts ... as an argument
if ("..." %in% names(formals(fun))) {
Expand Down

0 comments on commit 2eee97a

Please sign in to comment.