EvaluationError

Enum EvaluationError 

Source
pub enum EvaluationError {
Show 14 variants TypeError(String), InvalidArgument(String), UndefinedVariable(String), InvalidOperation(String), InvalidArity(String), InvalidIndex(String), DivisionByZero, ArithmeticOverflow, InvalidRegex(String), InvalidTypeSpecifier(String), SingletonEvaluationError(String), SemanticError(String), UnsupportedFunction(String), Other(String),
}
Expand description

Comprehensive error type for FHIRPath evaluation failures.

This enum covers all categories of errors that can occur during FHIRPath expression evaluation, from type mismatches to semantic violations. Each variant provides specific context about the failure to aid in debugging and error reporting.

§Error Categories

  • Type Errors: Mismatched types in operations or function calls
  • Argument Errors: Invalid arguments passed to functions
  • Runtime Errors: Errors during expression evaluation (division by zero, etc.)
  • Semantic Errors: Violations of FHIRPath semantic rules
  • System Errors: Internal errors and edge cases

§Error Handling

All variants implement std::error::Error and Display for standard Rust error handling patterns. The error messages are designed to be user-friendly and provide actionable information for debugging.

§Examples

use helios_fhirpath_support::EvaluationError;

// Type error example
let error = EvaluationError::TypeError(
    "Cannot add String and Integer".to_string()
);

// Display the error
println!("{}", error); // "Type Error: Cannot add String and Integer"

Variants§

§

TypeError(String)

Type mismatch or incompatible type operation.

Occurs when operations are attempted on incompatible types or when functions receive arguments of unexpected types.

Example: “Expected Boolean, found Integer”

§

InvalidArgument(String)

Invalid argument provided to a function.

Occurs when function arguments don’t meet the required constraints or format expectations.

Example: “Invalid argument for function ‘where’”

§

UndefinedVariable(String)

Reference to an undefined variable.

Occurs when expressions reference variables that haven’t been defined in the current evaluation context.

Example: “Variable ‘%undefinedVar’ not found”

§

InvalidOperation(String)

Invalid operation for the given operand types.

Occurs when operators are used with incompatible operand types or when operations are not supported for the given types.

Example: “Cannot add String and Integer”

§

InvalidArity(String)

Incorrect number of arguments provided to a function.

Occurs when functions are called with too many or too few arguments compared to their specification.

Example: “Function ‘substring’ expects 1 or 2 arguments, got 3”

§

InvalidIndex(String)

Invalid array or collection index.

Occurs when collection indexing operations use invalid indices (negative numbers, non-integers, out of bounds).

Example: “Index must be a non-negative integer”

§

DivisionByZero

Attempted division by zero.

Occurs during mathematical operations when the divisor is zero. This is a specific case of arithmetic error with clear semantics.

§

ArithmeticOverflow

Arithmetic operation resulted in overflow.

Occurs when mathematical operations produce results that exceed the representable range of the target numeric type.

§

InvalidRegex(String)

Invalid regular expression pattern.

Occurs when regex-based functions receive malformed regex patterns that cannot be compiled.

Example: “Invalid regex pattern: unclosed parenthesis”

§

InvalidTypeSpecifier(String)

Invalid type specifier in type operations.

Occurs when type checking operations (is, as, ofType) receive invalid or unrecognized type specifiers.

Example: “Unknown type ‘InvalidType’”

§

SingletonEvaluationError(String)

Collection cardinality error for singleton operations.

Occurs when operations expecting a single value receive collections with zero or multiple items.

Example: “Expected singleton, found collection with 3 items”

§

SemanticError(String)

Semantic rule violation.

Occurs when expressions violate FHIRPath semantic rules, such as accessing non-existent properties in strict mode or violating contextual constraints.

Example: “Property ‘invalidField’ does not exist on type ‘Patient’”

§

UnsupportedFunction(String)

Unsupported function called.

Occurs when a FHIRPath function is recognized but not yet implemented in this evaluation engine.

Example: “Function ‘conformsTo’ is not implemented”

§

Other(String)

Generic error for cases not covered by specific variants.

Used for internal errors, edge cases, or temporary error conditions that don’t fit into the specific error categories.

Example: “Internal evaluation error”

Trait Implementations§

Source§

impl Clone for EvaluationError

Source§

fn clone(&self) -> EvaluationError

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EvaluationError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for EvaluationError

Implements the Display trait for user-friendly error messages.

Provides formatted, human-readable error messages that include error category prefixes for easy identification of error types.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for EvaluationError

Implements the standard Error trait for EvaluationError.

This allows EvaluationError to be used with Rust’s standard error handling mechanisms, including ? operator, Result combinators, and error chains.

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for EvaluationError

Source§

fn eq(&self, other: &EvaluationError) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for EvaluationError

Source§

impl StructuralPartialEq for EvaluationError

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.