R/stop.R

Defines functions stop_via stopn

# Provide error function that can refer to the calling function.
stopn <- function(..., n = sys.nframe()) {
  stop(..., call. = FALSE)
}


# Error and provide calling function:
stop_via <- function(..., FUNCTION) {
  if (missing(FUNCTION)) stop(...)
  error_message <- paste0(..., collapse = "")
  caller <- as.name(FUNCTION)
  stop(structure(class = c("error", "condition"),
                 list(message = error_message,
                      call = caller)))
}

Try the grattan package in your browser

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

grattan documentation built on Sept. 4, 2023, 5:08 p.m.