condition: Create a condition object.

Description Usage Arguments Value Examples

View source: R/Exceptions.R

Description

Create an S3 object of class "condition" for use in R's condition handling system and as a base class for an exception class hierarchy.

Usage

1
condition(message = "condition", call = NULL)

Arguments

message

A one-element character vector describing this condition/event. By default this is "condition". It is fine to set this NULL as some subclasess will not need it (i.e. an extension class that only holds named data.)

call

The call or calls that were in process when this condition or event was generated. By default this is NULL as conditions need not be code related events (e.g. may be due to events triggered by environmental conditions or timers, etc.). sys.calls() can be used to obtain the whole call stack, and sys.call() can be used to access a single call.

Value

A condition object, of class "condition".

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
e <- condition()
conditionMessage( e )
conditionCall( e )

cond <- condition( "Something happened.", call= sys.calls() )

## Not run: 
   # Catch a "condition" class error and turn it into a warning instead.
   tryCatch(
        { stop(cond) },
        condition= function(e) { warning(e) }
   )

## End(Not run)

jefferys/Exception documentation built on May 19, 2019, 3:59 a.m.