R/util_find_first_externally_called_functions_in_stacktrace.R

Defines functions util_find_first_externally_called_functions_in_stacktrace

Documented in util_find_first_externally_called_functions_in_stacktrace

#' Find first externally called function in the stack trace
#'
#' intended use: error messages for the user
#'
#' @param sfs reverse [sys.frames] to search in
#' @param cls reverse [sys.calls] to search in
#'
#' @return reverse [sys.frames] index of first non-dataquieR function in
#'         this stack
#'
util_find_first_externally_called_functions_in_stacktrace <-
  function(sfs = rev(sys.frames()), cls = rev(sys.calls())) {
  first <- util_find_external_functions_in_stacktrace(sfs, cls)
  if (length(first) == 0) {
    NA_integer_
  } else {
    head(first, 1) - 2
  }
}

Try the dataquieR package in your browser

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

dataquieR documentation built on July 26, 2023, 6:10 p.m.