pub enum ExprError {
EmptyInput,
ParseFailed {
source: LexError,
input: String,
},
Missing,
}Expand description
Error type for expression parsing failures.
This enum captures different categories of expression parsing errors and provides descriptive error information for proper error handling.
§Examples
use hedl_test::{try_expr, ExprError};
// Handle invalid syntax
match try_expr("invalid syntax!") {
Err(ExprError::ParseFailed { source, input }) => {
println!("Failed to parse: {}", input);
println!("Reason: {}", source);
}
Ok(expr) => println!("Success"),
_ => {}
}
// Handle empty input
match try_expr("") {
Err(ExprError::EmptyInput) => {
println!("Expression cannot be empty");
}
_ => {}
}Variants§
EmptyInput
Expression string is empty.
ParseFailed
Expression parsing failed with a lexical error.
Contains the underlying LexError and the original input string
for context in error reporting.
Fields
Missing
Expression is missing (null or not provided).
Used when an expression is expected but not found.
Trait Implementations§
Source§impl Error for ExprError
impl Error for ExprError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
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
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for ExprError
impl RefUnwindSafe for ExprError
impl Send for ExprError
impl Sync for ExprError
impl Unpin for ExprError
impl UnwindSafe for ExprError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more