knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-"
)

Exceptional - Better exception handling for R

The goal of exceptional is to create better exception handling. This is achived by:

Example

This is a basic example:

library("exceptional")

Instead of

message("I am pretty urgent")

We could do

my_alert <- create_exception(
  create_message(default = "I am pretty urgent"), 
  nature = "warning", 
  cause = "because the weather is getting bad. Look at the clouds",
  parameter = letters[1:3],
  id = create_id("mypackage", 1)
)

my_alert
my_alert$parameter

Exceptions should have a unique id composed of the package name and a number and may be documented.

my_alert$id
my_alert$cause

We can also create different messages depending on the language setting.

f <- function() {
  msg <- create_message(default = "That's in english", de = "Deutsche Nachricht")
  create_exception(msg, nature = "error")
}
Sys.setenv(LANG = "en")
f()

Sys.setenv(LANG = "de")
f()


lorenzwalthert/exceptional documentation built on May 19, 2019, 4:10 p.m.