File: stopifnot.R

package info (click to toggle)
r-cran-openssl 1.2.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,136 kB
  • sloc: ansic: 2,033; sh: 19; makefile: 5
file content (10 lines) | stat: -rw-r--r-- 365 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
# custom stopifnot() that includes a stack trace
stopifnot <- function(...){
  expr <- as.list(match.call(expand.dots = TRUE)[-1])
  values <- vapply(list(...), isTRUE, logical(1))
  if(!all(values)){
    cl <- utils::tail(sys.calls(), 2)[[1]]
    err <- sprintf("check failed: (%s)", deparse(expr[[which(!values)[1]]]))
    stop(simpleError(err, call = cl))
  }
}