nyandere 0.1.2

i help with keeping track of purchases. meow
Documentation
//! All kinds of runtime errors.

use thiserror::Error;

use crate::{
    Name,
    aux::Owned,
    ext::shop::Gtin,
    runtime::model::{Entity, Object},
};

#[derive(Owned!, thiserror::Error)]
#[error("could not construct command from source code")]
pub enum Construction {
    UnknownActor(#[from] UnknownActor),
    Same(#[from] Same),
    Unspecified(#[from] PriceUnspecified),
    BothZero(#[from] BothZero),
}

#[derive(Owned!, Error)]
#[error("unknown actor -- maybe a typo? if you're sure it's not one, create it")]
pub enum UnknownActor {
    Entity(#[from] UnknownEntity),
    Concept(#[from] UnknownConcept),
    ConceptGtin(#[from] UnknownConceptGtin),
    Object(#[from] UnknownObject),
}

#[derive(Owned!, thiserror::Error)]
#[error("unknown entity {0}")]
pub struct UnknownEntity(pub Name);

#[derive(Owned!, thiserror::Error)]
#[error("unknown concept {0}")]
pub struct UnknownConcept(pub Name);

#[derive(Owned!, thiserror::Error)]
#[error("unknown concept {0}")]
pub struct UnknownConceptGtin(pub Gtin);

#[derive(Owned!, thiserror::Error)]
#[error("unknown object or concept {0}")]
pub struct UnknownObject(pub Name);

/// There is no reason for a noop in money processing. Likely a typo.
#[derive(Owned!, Error)]
#[error("{0} and {1} are the same, but mustn't be")]
pub struct Same(pub Entity, pub Entity);

/// The price of that object is not specified and
/// could not be inferred.
///
/// If that is intentional as it's a gift, specify `0` as price.
/// Otherwise, see if you might need to update a concept definition.
#[derive(Owned!, thiserror::Error)]
#[error("cannot deliver {object} without knowing the money expected in return at some point -- specify 0 if it's a gift")]
pub struct PriceUnspecified {
    pub object: Object,
}

#[derive(Owned!, thiserror::Error)]
#[error("tried to construct a ratio with both parts being zero, at least one of them has to be zero")]
pub struct BothZero;