R/utils,conditions.R

Defines functions msgf warnf stopf

stopf <- function(fmt, ..., call. = TRUE, domain = NULL) {  #nolint
  msg <- sprintf(fmt, ...)
  msg <- .makeMessage(msg, domain = domain)
  if (is.call(call.)) {
    call <- call.
  } else if (isTRUE(call)) {
    call <- sys.call(which = -1L)
  } else {
    call <- NULL
  }
  cond <- simpleError(msg, call = call)
  stop(cond)
}

warnf <- function(fmt, ..., call. = TRUE, immediate. = FALSE, domain = NULL) {  #nolint
  msg <- sprintf(fmt, ...)
  ## Cannot tweak 'call' when immediate. = TRUE
  if (isTRUE(immediate.)) {
    warning(msg, call. = call., immediate. = immediate., domain = domain)
  } else {
    msg <- .makeMessage(msg, domain = domain)
    if (is.call(call.)) {
      call <- call.
    } else if (isTRUE(call)) {
      call <- sys.call(which = -1L)
    } else {
      call <- NULL
    }
    cond <- simpleWarning(msg, call = call)
    warning(cond)
  }
}

msgf <- function(fmt, ..., appendLF = FALSE, domain = NULL) {  #nolint
  message(sprintf(fmt, ...), appendLF = appendLF, domain = domain)
}

Try the future package in your browser

Any scripts or data that you put into this service are public.

future documentation built on Sept. 11, 2024, 7:35 p.m.