Err: Create an 'Err' Result

Description Usage Arguments Value Examples

View source: R/result_option.R

Description

Create an Enum variant of Result used to denote that function contained an error. This allows the creation of safer functions that do not automatically stop, without using try or tryCatch.

Usage

1
Err(e)

Arguments

e

Object to be wrapped in the Enum variant.

Value

a list with a single value e and classes "Result} and \code{"Enum

Examples

1
2
3
4
5
6
7
8
grepl_safe <- function(pattern, x)
{
  if (!is.character(pattern)){ return(Err("'pattern' in 'grepl_safe' was not a character value.")) }
  if (!is.character(x)){ return(Err("'x' in 'grepl_safe' was not a character value.")) }
  Ok(grepl(pattern, x))
}

#grepl_safe(123, 1:5)

matchr documentation built on Sept. 9, 2021, 5:07 p.m.

Related to Err in matchr...