Skip to main content

conversion_err_parts

Function conversion_err_parts 

Source
#[doc(hidden)]
pub fn conversion_err_parts( prefix: &str, param: &str, rust_type: Option<&str>, crate_class: &[&str], parts: ErrParts, arg_message: Option<String>, ) -> ErrParts
Expand description

Combine an argument-conversion error’s own parts with the wrapper’s parameter context.

  • The message becomes <prefix>: <error message>. For an argument the macro writes the prefix in R terms (#1591): '<p>' must be <expected> when it knows what the argument should be ('x' must be a single integer, 'dv' must be numeric), invalid '<p>' argument otherwise. A sidecar setter passes its own prefix. An error that words the whole argument error itself, a match_arg choice error (#1767) or one with an argument_message (#1833), gives arg_message (crate::__mx_conversion_arg_message!), which is the message instead.
  • The class vector is the error’s own (empty for the built-in and Display arms), followed by crate_class, the crate’s conversion_error_class from [package.metadata.miniextendr], minus any class the error already names. The R helper appends the rust_error layering after both.
  • param (the parameter’s R name) is added as the first data field, e$param, and rust_type (the Rust type as written in the signature, when given) after it, e$rust_type. Neither is added when the error’s own data already has a field of that name: the type author’s value is kept, since the framework never overwrites a field the type author chose, and R’s e$name reads only the first of two same-named fields.
  • The call is always the wrapper’s (ConditionCall::Inherit), whatever the error type’s RConditionData::call says: the R-side checks (.miniextendr_arg_error) raise the same condition with the call (#1591), and an argument error must not differ by which side caught it.