InvalidRateError carries no detail and admits no future fields #13

Open
opened 2026-08-14 21:13:11 +00:00 by rosa · 0 comments
Owner

InvalidRateError (src/exchange.rs:434) is a bare unit struct. Two
consequences:

  • It carries no detail. The rate that was refused is discarded, so a caller
    handling the error cannot report which value was at fault. The struct is
    Copy, and a Decimal field would keep it so.
  • It is not #[non_exhaustive], so downstream code can construct it, and adding
    that field later is a breaking change.

Every multi-field error in the crate is already #[non_exhaustive]
MoneyError (src/lib.rs:1206), IsoAlphabeticCodeError (src/lib.rs:1230),
IsoNumericCodeError (src/lib.rs:1239).

UnknownCurrencyError (src/lib.rs:1226) has the same shape and the same gap,
so this is a decision to make across the crate rather than in exchange.rs
alone.

Guideline: C-GOOD-ERR.

`InvalidRateError` (`src/exchange.rs:434`) is a bare unit struct. Two consequences: - It carries no detail. The rate that was refused is discarded, so a caller handling the error cannot report which value was at fault. The struct is `Copy`, and a `Decimal` field would keep it so. - It is not `#[non_exhaustive]`, so downstream code can construct it, and adding that field later is a breaking change. Every multi-field error in the crate is already `#[non_exhaustive]` — `MoneyError` (`src/lib.rs:1206`), `IsoAlphabeticCodeError` (`src/lib.rs:1230`), `IsoNumericCodeError` (`src/lib.rs:1239`). `UnknownCurrencyError` (`src/lib.rs:1226`) has the same shape and the same gap, so this is a decision to make across the crate rather than in `exchange.rs` alone. Guideline: C-GOOD-ERR.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rosa/lucre#13
No description provided.