calternal_money::error
One error type for the Money codec and maths.
Every rejection carries a kind (so the API can map it to a stable error code) and a human message that names the offending row or value. The maths never returns a partial result: a ledger that cannot be posted exactly is an error as a whole (DESIGN §48: a malformed row must not vanish silently).
Source: crates/calternal-money/src/error.rs
Structs
Section titled “Structs”MoneyError
Section titled “MoneyError”pub struct MoneyErrorA Money rejection. See the module documentation.
Fields
pub kind: ErrorKind: The class of problem.pub message: String: A short English message; it may quote file text, never other Users’ data.
Implements: Clone, Debug, Eq, PartialEq, fmt::Display, std::error::Error
MoneyError::invalid
Section titled “MoneyError::invalid”pub fn invalid(message: impl Into<String>) -> SelfA format or posting rule was broken.
MoneyError::currency
Section titled “MoneyError::currency”pub fn currency(code: &str) -> SelfAn unsupported currency code.
MoneyError::range
Section titled “MoneyError::range”pub fn range() -> SelfA value outside the exact range.
MoneyError::unsupported
Section titled “MoneyError::unsupported”pub fn unsupported(message: impl Into<String>) -> SelfA format feature this build reads but does not edit yet.
MoneyError::not_found
Section titled “MoneyError::not_found”pub fn not_found(message: impl Into<String>) -> SelfA missing block ID.
Source: crates/calternal-money/src/error.rs:29
ErrorKind
Section titled “ErrorKind”pub enum ErrorKindWhat class of problem a MoneyError reports.
Variants
Invalid: The file or input breaks the Money format or a posting rule.Currency: A currency code is unknown or has no numeric minor unit.Range: A value or total leaves the exact range±MAX_EXACTminor units.Unsupported: The operation is valid in the format but not supported by this build (for example editing a split row, #462).NotFound: A referenced block ID does not exist.
Implements: Clone, Copy, Debug, Eq, PartialEq, Serialize
Source: crates/calternal-money/src/error.rs:13
Type aliases
Section titled “Type aliases”Result
Section titled “Result”pub type Result<T> = std::result::Result<T, MoneyError>;Result alias for the Money crate.