captureStackTraces runs the given expr and if any
uncaught errors occur, annotates them with stack trace info for use
by printError and printStackTrace. It is not necessary to use
captureStackTraces around the same expression as
withLogErrors, as the latter includes a call to the former. Note
that if expr contains calls (either directly or indirectly) to
try, or tryCatch with an error handler, stack traces therein
cannot be captured unless another captureStackTraces call is
inserted in the interior of the try or tryCatch. This is
because these calls catch the error and prevent it from traveling up to the
condition handler installed by captureStackTraces.
withLogErrors captures stack traces and logs errors that
occur in expr, but does allow errors to propagate beyond this point
(i.e. it doesn't catch the error). The same caveats that apply to
captureStackTraces with regard to try/tryCatch apply
to withLogErrors.
printError prints the error and stack trace (if any) using
warning(immediate.=TRUE). printStackTrace prints the stack
trace only.
extractStackTrace takes a list of calls (e.g. as returned
from conditionStackTrace(cond)) and returns a data frame with one
row for each stack frame and the columns num (stack frame number),
call (a function name or similar), and loc (source file path
and line number, if available). It was deprecated after shiny 1.0.5 because
it doesn't support deep stack traces.
formatStackTrace is similar to extractStackTrace, but
it returns a preformatted character vector instead of a data frame. It was
deprecated after shiny 1.0.5 because it doesn't support deep stack traces.
conditionStackTrace and conditionStackTrace<- are
accessor functions for getting/setting stack traces on conditions.
The two functions ..stacktraceon.. and
..stacktraceoff.. have no runtime behavior during normal execution;
they exist only to create artifacts on the stack trace (sys.call()) that
instruct the stack trace pretty printer what parts of the stack trace are
interesting or not. The initial state is 1 and we walk from the outermost
call inwards. Each ..stacktraceoff.. decrements the state by one, and each
..stacktraceon.. increments the state by one. Any stack trace frame whose
value is less than 1 is hidden, and finally, the ..stacktraceon.. and
..stacktraceoff.. calls themselves are hidden too.