knitr::opts_chunk$set(
  error = TRUE,
  collapse = TRUE,
  comment = "#>"
)
library(attempt)

Introduction to {attempt}

{attempt}

Tools for defensive programming, inspired by {purrr} mappers and based on {rlang}.

{attempt} is designed to handle the cases when something / someone attempts to do something it shouldn't.

For example:

{attempt} provides several condition handlers, from try catch to simple message printing.

{attempt} only depends on {rlang}, and every function is design to be fast, making it easy to implement in other functions and packages.

Install

From CRAN:

install.packages("attempt")

The dev version:

install.packages("attempt", repo = "https://colinfay.me/ran", type = "source")

Using {attempt}

{attempt} provides four families of functions :

try catch

Try catch functions are a family of functions which are used to deal with errors and warnings.

adverbs

Adverbs take a function and return a modified function.

if

conditions

About mappers

Mappers are functions built like one sided formulas.

In other words, ~ .x + 2 is the equivalent of function(x) return(x + 2).

The first argument in a mapper need to be .x.

More on mappers.

Misc

Acknowledgments

Thanks to Romain for the name suggestion.

Contact

Questions and feedbacks welcome!

You want to contribute ? Open a PR :) If you encounter a bug or want to suggest an enhancement, please open an issue.



ColinFay/trycatchthis documentation built on Dec. 31, 2022, 3:59 a.m.