Skip to main content

dpp_calc/kernel/
error.rs

1//! Error type for all calculator operations in `dpp-calc`.
2
3#[derive(Debug, thiserror::Error)]
4pub enum CalcError {
5    #[error("invalid input: {0}")]
6    InvalidInput(String),
7
8    /// The ruleset's effective period has ended; a newer version is required.
9    #[error("ruleset '{id}' expired on {until}")]
10    RulesetExpired { id: String, until: String },
11
12    /// The ruleset's effective period has not started yet (e.g. a pending
13    /// delegated act using the `2100-01-01` sentinel).
14    #[error("ruleset '{id}' is not yet effective (in force from {from})")]
15    RulesetNotYetEffective { id: String, from: String },
16
17    /// A computation overflowed to a non-finite value despite finite, in-range
18    /// inputs — a legally cited figure must never silently become Infinity.
19    #[error("calculation overflow: {0}")]
20    Overflow(String),
21
22    /// The requested activity UUID is not present in the injected factor dataset.
23    #[error("emission factor not found for activity '{0}'")]
24    FactorNotFound(String),
25
26    /// The supplied data cannot be processed by this methodology.
27    #[error("methodology mismatch: {0}")]
28    MethodologyMismatch(String),
29
30    /// The methodology is defined but not yet implemented (gate: data license / delegated act).
31    #[error("not implemented: {methodology} — {reason}")]
32    NotImplemented { methodology: String, reason: String },
33
34    /// A parameter combination that is internally incoherent per the ruleset.
35    #[error("cross-field validation failed: {0}")]
36    CrossFieldViolation(String),
37
38    /// JSON canonicalization failed — inputs or outputs could not be serialized.
39    #[error("canonicalization error: {0}")]
40    CanonicalizeError(String),
41}