use ifc_model::EntityId;
use thiserror::Error;
#[derive(Debug, Clone, PartialEq, Error)]
#[non_exhaustive]
pub enum ControlError {
#[error("expected {expected}, found {actual}")]
WrongEntityType {
expected: &'static str,
actual: String,
},
#[error("{entity} {id} is missing {attribute}")]
MissingAttribute {
entity: &'static str,
id: EntityId,
attribute: &'static str,
},
#[error("entity {id} does not exist")]
UnknownEntity {
id: EntityId,
},
#[error("cannot author {entity}.{attribute}: {value}")]
AuthoringInvalid {
entity: &'static str,
attribute: &'static str,
value: String,
},
#[error("{id} is {actual}, not a control ifc-control owns")]
ForeignControl {
id: EntityId,
actual: String,
},
#[error("{schema} does not declare {entity}")]
UnsupportedEntity {
schema: String,
entity: &'static str,
},
#[error("the header declares {schemas} schemas; authoring binds to exactly one")]
MultipleSchemas {
schemas: usize,
},
#[error("the header declares {schema}, which has no bundled table")]
UnsupportedSchema {
schema: String,
},
#[error("cannot author {entity}.{attribute}: not declared by {schema}")]
AuthoringNotInSchema {
entity: &'static str,
attribute: &'static str,
schema: String,
},
#[error("cannot author {entity}.{attribute}: {schema} declares it {declared}")]
AuthoringValueType {
entity: &'static str,
attribute: &'static str,
declared: String,
schema: String,
},
#[error("cannot author {entity}: {schema} requires {attribute}")]
AuthoringRequired {
entity: &'static str,
attribute: String,
schema: String,
},
}
pub type ControlResult<T> = Result<T, ControlError>;