Skip to main content

ifc_cost/
error.rs

1//! Why a cost lookup failed.
2
3use thiserror::Error;
4
5/// Failures specific to interpreting cost data.
6#[derive(Debug, Error)]
7#[non_exhaustive]
8pub enum CostError {
9    /// An entity was expected to be a cost entity but is not.
10    #[error("entity #{id} is {actual}, not {expected}")]
11    WrongType {
12        /// The entity id.
13        id: u64,
14        /// The type it actually has.
15        actual: String,
16        /// The type that was expected.
17        expected: &'static str,
18    },
19
20    /// A referenced cost value or quantity does not exist.
21    #[error("cost item #{from} references missing entity #{to}")]
22    MissingReference {
23        /// The referring cost item.
24        from: u64,
25        /// The missing target.
26        to: u64,
27    },
28}