ennotify: 'entrace()' + 'notify()'

View source: R/ennotify.R

ennotifyR Documentation

entrace() + notify()

Description

ennotify() adds a backtrace to base R errors and sends a notification email with the failing function and a full backtrace. However, it cannot capture the condition object associated with the error, and thus cannot show error messages. Logging errors is highly recommended.

The helpers ennotify_to() and ennotify_context() assist in setting global parameters to make your message more informative (and go to the right people!). See below for details.

Set ennotify() as your error handler using

options(error = quote(coviData::ennotify()), rlang_backtrace_on_error = "full")

There are several options used by ennotify() to customize output. The easiest way to set these options is to use ennotify_set_options().

The first is "ennotify_to"; this is a character vector containing recipient email addresses for error notifications. This can be set most easily using ennotify_to(to = your_recipients), and retrieved most easily using ennotify_to() with no arguments.

The second is "ennotify_context"; this allows the user to fill in the context in which the error occurred. This should make sense in the sentence "foo() in ennotify_context encountered an error." This can be set most easily using ennotify_context(context = your_context), and retrieved most easily using ennotify_context() with no arguments.

The third is ennotify_inform; this allows easy switching of message printing for ennotify_context(). This is mostly useful for printing logging messages. This can be set most easily using ennotify_inform(TRUE) or ennotify_inform(FALSE), and retrieved with ennotify_inform().

If "ennotify_to" is unset, the function currently emails me (Jesse Smith) every time an error is processed, so please do not use this before consulting me first. This function is only exported to allow usage in scripts and other Shelby County R packages.

In the event of an internal error, the error will be printed to stderr, but execution will continue.

Usage

ennotify()

ennotify_set_options(
  ...,
  .inform = TRUE,
  .backtrace = c("full", "collapse", "branch", "reminder")
)

ennotify_to(...)

ennotify_context(context, inform = ennotify_inform())

ennotify_inform(inform)

Arguments

...

Character vectors of recipient email addresses

context

Character. The context for an error, if one occurs.

inform

Should ennotify_context() print a message to stderr when called?


jesse-smith/coviData documentation built on Jan. 14, 2023, 11:08 a.m.