Learn R Programming

erratum (version 2.2.0)

latch: Latch an Error or a Warning

Description

Latch an error or a warning to an object to indicate an issue associated with it. These can later be checked with is.e() and is.w(), and can also be resolve().

Usage

latch.e(obj, error)

latch.w(obj, warning)

unlatch(obj)

Arguments

obj

Object to latch the error or warning onto.

error, warning

Error or warning, the output of e() or w().

Functions

  • latche and latchw: latch an error or a warning.

  • unlatch: unlatch any error or warning.

Examples

Run this code
# NOT RUN {
x <- 1
problematic <- latch.e(x, e("Not right"))

is.e(problematic)

do_sth_with_x <- function(x){
 resolve(x)
 x + 1
}

if(interactive()){
 do_sth_with_x(x)
 do_sth_with_x(problematic)
}

unlatch(problematic)

# }

Run the code above in your browser using DataLab