#[non_exhaustive]pub enum MathError {
}Expand description
Every failure mode MathVerse recognizes.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Domain
Input outside the function’s domain (e.g. ln(-1)).
DivisionByZero
Division or modulus by zero.
InvalidArgument(&'static str)
A parameter was invalid; carries a human-readable reason.
NotConverged(&'static str)
An iterative method failed to converge.
DimensionMismatch
Matrix/vector shapes don’t line up.
Overflow
Result exceeded the representable range.
Underflow
Result fell below the representable range.
Singular
Matrix is not invertible.
Timeout
Computation exceeded a time or iteration limit.
Io
I/O operation failed.
Parse
Parsing of a string or expression failed.
NotImplemented
Feature or operation not yet implemented.
OutOfRange
Value outside a valid range.
NoSolution
No solution exists for the given inputs.
InfiniteSolutions
Infinitely many solutions exist.
InvalidBase
Base of a number system is invalid.
NegativeInput
Input must be non-negative.
Implementations§
Source§impl MathError
impl MathError
Sourcepub const fn msg(&self) -> &'static str
pub const fn msg(&self) -> &'static str
Returns a human-readable description of the error.
§Examples
use mathverse_core::error::MathError;
assert_eq!(MathError::Domain.msg(), "input is outside the function domain");
assert_eq!(MathError::DivisionByZero.msg(), "division by zero");
assert_eq!(MathError::Overflow.msg(), "numeric overflow");Sourcepub const fn has_context(&self) -> bool
pub const fn has_context(&self) -> bool
Returns true if this error variant carries a custom message.
§Examples
use mathverse_core::error::MathError;
assert!(MathError::InvalidArgument("bad").has_context());
assert!(!MathError::Domain.has_context());Trait Implementations§
impl Eq for MathError
Source§impl Error for MathError
Available on crate feature std only.
impl Error for MathError
std only.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()