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);
#[derive(Owned!, Error)]
#[error("{0} and {1} are the same, but mustn't be")]
pub struct Same(pub Entity, pub Entity);
#[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;