R/utils.R

Defines functions .stop_if_not

.stop_if_not <- function(...) {
  res <- list(...)
  n <- length(res)
  if (n == 0L) return()

  for (ii in 1L:n) {
    res_ii <- .subset2(res, ii)
    if (length(res_ii) != 1L || is.na(res_ii) || !res_ii) {
        mc <- match.call()
        call <- deparse(mc[[ii + 1]], width.cutoff = 60L)
        if (length(call) > 1L) call <- paste(call[1L], "...")
        stop(sQuote(call), " is not TRUE but ", call. = FALSE, domain = NA)
    }
  }
}
HenrikBengtsson/PSCBS documentation built on Feb. 20, 2024, 9:01 p.m.