knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-" )
The goal of exceptional is to create better exception handling. This is achived by:
warning()
or stop()
can deliver. Again, this is
possible through the class "exceptional".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()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.