Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admit custom condition for input validation errors #25

Closed
egnha opened this issue Apr 9, 2017 · 1 comment
Closed

Admit custom condition for input validation errors #25

egnha opened this issue Apr 9, 2017 · 1 comment

Comments

@egnha
Copy link
Owner

egnha commented Apr 9, 2017

If an input validation error occurs, firmly signals a simpleError. For more discriminating error handling downstream, firmly should be allowed to signal other classes of errors. In other words, firmly should have a character-vector parameter .error_class that gives the subclass of the condition, inheriting from c("error", "condition") (default value "simpleError"), that is to be signaled by an input validation error.

New signature should be

firmly(.f, ..., .checklist = list(),
       .warn_missing = character(), .error_class = character())
@egnha
Copy link
Owner Author

egnha commented Apr 9, 2017

And update %secure%, accordingly:

`%secure%` <- function(args, f) {
  nms <- names(args) %||% character(length(args))
  firmly(
    f,
    .checklist    = args[!nms %in% c(".warn_missing", ".error_class")],
    .warn_missing = args[[".warn_missing"]] %||% character(),
    .error_class  = args[[".error_class"]] %||% character()
  )
}

(No need for %secure% to check types, since firmly() will do that for itself.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant