Skip to main content

Module conditions

Module conditions 

Source
Expand description

§Condition objects

In R, a condition is an S3 list with:

  • message: a character vector describing the condition
  • call: the call that triggered the condition, or NULL
  • a class attribute including "condition" and optionally "error", "warning", or "message"

rlang conditions may include trace and parent fields, which are represented as Option<List> and Option<RCondition> respectively.

§Types

This module provides four types:

  • ConditionKind: an enum discriminating the base R condition type (condition, message, warning, error).

  • Condition: a Rust-native representation. Construct one with ConditionBuilder::default(). This is the primary type we encourage you to work with for its ergonomics due to its use of std types.

  • RCondition: a thin wrapper around a List that already exists in R memory as a proper condition object. Use this when receiving or returning condition objects at the R boundary.

  • ConditionBuilder: a builder for Condition. Create a builder with ConditionBuilder::default() to start, chain setters, and call .build() to produce a Condition.

§Conversions

From \ ToListRConditionRobjCondition
ConditionFromFromFrom
ListTryFromblanketTryFrom
&ListTryFromTryFrom
RConditionFromFromTryFrom
RobjTryFromTryFrom
&RobjTryFromTryFrom

Structs§

Condition
Rust-native representation of an R condition.
ConditionBuilder
Builder for constructing a Condition.
RCondition
A validated R condition object held as a List.

Enums§

ConditionKind
Discriminates the kind of R condition being constructed.

Functions§

format_cnd_message
Format an error message with rlang-style bullets.
format_warn_message
Format a warning message with rlang-style bullets.