Skip to content

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

pub struct MoneyError

A 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

pub fn invalid(message: impl Into<String>) -> Self

A format or posting rule was broken.

pub fn currency(code: &str) -> Self

An unsupported currency code.

pub fn range() -> Self

A value outside the exact range.

pub fn unsupported(message: impl Into<String>) -> Self

A format feature this build reads but does not edit yet.

pub fn not_found(message: impl Into<String>) -> Self

A missing block ID.

Source: crates/calternal-money/src/error.rs:29

pub enum ErrorKind

What 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_EXACT minor 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

pub type Result<T> = std::result::Result<T, MoneyError>;

Result alias for the Money crate.

Source: crates/calternal-money/src/error.rs:87