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 requested activity UUID is not present in the injected factor dataset.
13    #[error("emission factor not found for activity '{0}'")]
14    FactorNotFound(String),
15
16    /// The supplied data cannot be processed by this methodology.
17    #[error("methodology mismatch: {0}")]
18    MethodologyMismatch(String),
19
20    /// The methodology is defined but not yet implemented (gate: data license / delegated act).
21    #[error("not implemented: {methodology} — {reason}")]
22    NotImplemented { methodology: String, reason: String },
23
24    /// A parameter combination that is internally incoherent per the ruleset.
25    #[error("cross-field validation failed: {0}")]
26    CrossFieldViolation(String),
27
28    /// JSON canonicalization failed — inputs or outputs could not be serialized.
29    #[error("canonicalization error: {0}")]
30    CanonicalizeError(String),
31}