etry {bettermc}R Documentation

Extended try

Description

Extended version of try with support for tracebacks and crash dumps.

Usage

etry(
  expr,
  silent = FALSE,
  outFile = getOption("try.outFile", default = stderr()),
  max.lines = 100L,
  dump.frames = c("partial", "full", "full_global", "no")
)

## S3 method for class ''etry-error''
print(
  x,
  max.lines = getOption("traceback.max.lines", getOption("deparse.max.lines", -1L)),
  ...
)

Arguments

expr

an R expression to try.

silent

logical: should the report of error messages be suppressed?

outFile

a connection, or a character string naming the file to print to (via cat(*, file = outFile)); used only if silent is false, as by default.

max.lines

for etry, the maximum number of lines to be deparsed per call. For print, the maximum number of lines to be printed per call. The default for the latter is unlimited.

dump.frames

should a crash dump (cf. dump.frames) be created in case of an error? The default "partial" omits the frames up to the call of etry. "full" and "no" do the obvious. "full_global" additionally also includes (a copy of) the global environment (cf. include.GlobalEnv argument of dump.frames).

x

an object of class "etry-error".

...

further arguments passed to or from other methods.

Value

For etry, the value of the expression if expr is evaluated without error, but an invisible object of class c("etry-error", "try-error") containing the error message if it fails. This object has three attributes: (condition) the error condition, (traceback) the traceback as returned by .traceback, (dump.frames) the crash dump which can be examined using utils::debugger.

Windows Support

Fully supported on Windows.

Lifecycle

options:
  alt='[Stable]'


[Package bettermc version 1.1.2 Index]