Predicator.Errors.TypeMismatchError (predicator v2.2.0)
View SourceError struct for type mismatch errors in Predicator evaluation.
This error occurs when an operation receives values of incorrect types, such as trying to perform arithmetic on strings or logical operations on integers.
Fields
message
- Human-readable error descriptionexpected
- The type that was expected (e.g.,:integer
,:boolean
)got
- The actual type(s) received (single type or tuple for binary operations)values
- The actual value(s) that caused the error (optional, for debugging)operation
- The operation that failed (e.g.,:add
,:logical_and
)
Examples
%Predicator.Errors.TypeMismatchError{
message: "Arithmetic add requires integers, got "hello" (string) and 5 (integer)",
expected: :integer,
got: {:string, :integer},
values: {"hello", 5},
operation: :add
}
%Predicator.Errors.TypeMismatchError{
message: "Unary minus requires an integer, got "text" (string)",
expected: :integer,
got: :string,
values: "text",
operation: :unary_minus
}
Summary
Functions
Creates a type mismatch error for binary operations.
Creates a type mismatch error for unary operations.
Types
Functions
Creates a type mismatch error for binary operations.
Creates a type mismatch error for unary operations.