pub enum FormulaError {
Tokenize {
pos: usize,
char: char,
},
Parse {
pos: usize,
expected: &'static str,
got: String,
},
Eval(ExcelError),
UnknownFunction(String),
RecursionLimit,
InvalidRange,
}Expand description
The single crate-level error for tokenizing, parsing, and evaluation.
Excel values that signal failure (#DIV/0! …) ride in
FormulaError::Eval when produced by evaluation; see the module docs
for the value-vs-error channel contract.
Variants§
Tokenize
The tokenizer hit a character that cannot begin any token, a
malformed #error literal, an unterminated string, or a malformed
$-anchored reference. pos is the byte offset; char is the
offending character (the # or " that began the bad token, or the
unknown character itself).
Parse
The parser hit a token it could not accept. pos is the byte offset
of the offending token, expected a description of what would have
been legal, got the rendered offending token.
Fields
Eval(ExcelError)
An Excel error value was produced by evaluation (arithmetic,
coercion, a lookup miss, the #…! literal itself). Catchable by
IFERROR/IFNA/ISERROR/ISNA inside the formula; at the top
level this is the Err arm.
UnknownFunction(String)
A function name not in the built-in table was called. Excel would
show #NAME?; this crate makes unknown functions a hard, typed
error instead (rationale in the crate docs). The name is uppercased.
RecursionLimit
Parse or evaluation recursion exceeded
MAX_DEPTH. Returned instead of overflowing the
stack — the crate is stack-safe by construction, fuzz-verified.
InvalidRange
A range argument was structurally impossible: a non-reference where
a range is required (VLOOKUP(1, 5, 2)), or a range not shaped as
its function demands (a 2-D table handed to MATCH).
Implementations§
Source§impl FormulaError
impl FormulaError
Sourcepub const fn excel_error(&self) -> Option<ExcelError>
pub const fn excel_error(&self) -> Option<ExcelError>
The Excel worksheet error behind this failure, if any. Convenience
for callers that want to render #DIV/0!-style results.
Trait Implementations§
Source§impl Clone for FormulaError
impl Clone for FormulaError
Source§impl Debug for FormulaError
impl Debug for FormulaError
Source§impl Display for FormulaError
impl Display for FormulaError
impl Eq for FormulaError
Source§impl Error for FormulaError
impl Error for FormulaError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()