pub struct EvaluationError { /* private fields */ }Expand description
An evaluation failure that is neither a type mismatch nor an unbound variable, and a value refused where it crosses into the crate (a float that is not finite, a value nested too deep).
use predicator_rs::EvaluationError;
let error = EvaluationError::new("division_by_zero", "the divisor is zero");
assert_eq!(error.reason(), "division_by_zero");
assert_eq!(error.to_string(), "the divisor is zero");
assert_eq!(error.position(), None);Implementations§
Source§impl EvaluationError
impl EvaluationError
Sourcepub fn new(reason: impl Into<String>, message: impl Into<String>) -> Self
pub fn new(reason: impl Into<String>, message: impl Into<String>) -> Self
An error with a reason (the corpus’s token) and a message (a sentence for a person), at no position.
use predicator_rs::{EvaluationError, Position};
let error = EvaluationError::new("some_reason", "a sentence");
assert_eq!(error.reason(), "some_reason");
assert_eq!(error.position(), None);Sourcepub fn with_position(self, position: Position) -> Self
pub fn with_position(self, position: Position) -> Self
The same error at position.
use predicator_rs::{EvaluationError, Position};
let error = EvaluationError::new("some_reason", "a sentence");
let at = Position { line: 2, column: 3 };
assert_eq!(error.with_position(at).position(), Some(at));Sourcepub fn reason(&self) -> &str
pub fn reason(&self) -> &str
The reason: the structured token the corpus names, which is normative.
use predicator_rs::{EvaluationError, Position};
let error = EvaluationError::new("some_reason", "a sentence");
assert_eq!(error.reason(), "some_reason");Sourcepub fn message(&self) -> &str
pub fn message(&self) -> &str
The message: a sentence for a person, which is not normative.
use predicator_rs::{EvaluationError, Position};
let error = EvaluationError::new("some_reason", "a sentence");
assert_eq!(error.message(), "a sentence");
assert_eq!(error.to_string(), "a sentence");Sourcepub fn position(&self) -> Option<Position>
pub fn position(&self) -> Option<Position>
Where in the source the failure is, when that is known.
use predicator_rs::{EvaluationError, Position};
let error = EvaluationError::new("some_reason", "a sentence");
assert_eq!(error.position(), None);
let at = Position { line: 1, column: 1 };
assert_eq!(error.with_position(at).position(), Some(at));Source§impl EvaluationError
impl EvaluationError
Sourcepub fn root(&self) -> Option<&str>
pub fn root(&self) -> Option<&str>
The context root a refusal names, when it names one: the root a
store was refused because the options protect it (reason
protected_root; Options::protected_roots).
use predicator_rs::EvaluationError;
assert_eq!(EvaluationError::new("division_by_zero", "the divisor is zero").root(), None);Trait Implementations§
Source§impl Clone for EvaluationError
impl Clone for EvaluationError
Source§impl Debug for EvaluationError
impl Debug for EvaluationError
Source§impl Display for EvaluationError
impl Display for EvaluationError
impl Eq for EvaluationError
Source§impl Error for EvaluationError
impl Error for EvaluationError
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()
Source§impl From<EvaluationError> for Error
impl From<EvaluationError> for Error
Source§fn from(error: EvaluationError) -> Error
fn from(error: EvaluationError) -> Error
Converts to this type from the input type.
Source§impl PartialEq for EvaluationError
impl PartialEq for EvaluationError
impl StructuralPartialEq for EvaluationError
Auto Trait Implementations§
impl Forget for EvaluationError
impl Freeze for EvaluationError
impl Move for EvaluationError
impl RefUnwindSafe for EvaluationError
impl Send for EvaluationError
impl Sync for EvaluationError
impl Unpin for EvaluationError
impl UnsafeUnpin for EvaluationError
impl UnwindSafe for EvaluationError
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