use ifc_model::EntityId;
use thiserror::Error;
#[derive(Debug, Clone, PartialEq, Error)]
#[non_exhaustive]
pub enum ApprovalError {
#[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}.{attribute} is invalid: {value}")]
InvalidValue {
entity: &'static str,
id: EntityId,
attribute: &'static str,
value: String,
},
#[error("entity {id} does not exist")]
UnknownEntity {
id: EntityId,
},
#[error("{entity} {id}.{attribute} reference {target} does not resolve")]
DanglingReference {
entity: &'static str,
id: EntityId,
attribute: &'static str,
target: EntityId,
},
#[error("{entity} {id}.{attribute} target {target} has {actual}, expected {expected}")]
ReferenceType {
entity: &'static str,
id: EntityId,
attribute: &'static str,
target: EntityId,
expected: &'static str,
actual: String,
},
#[error("{entity} {id} violates {rule}: {detail}")]
Semantic {
entity: &'static str,
id: EntityId,
rule: &'static str,
detail: String,
},
#[error("cannot author {entity}.{attribute}: {value}")]
AuthoringInvalid {
entity: &'static str,
attribute: &'static str,
value: String,
},
#[error("authoring target {target} has {actual}, expected {expected}")]
AuthoringReferenceType {
target: EntityId,
expected: &'static str,
actual: String,
},
}
pub type ApprovalResult<T> = Result<T, ApprovalError>;