ifc_control/error.rs
1//! Typed failures for bounded IFC control semantics.
2
3use ifc_model::EntityId;
4use thiserror::Error;
5
6/// Control projection or authoring failure.
7///
8/// Only the variants this crate can actually raise are declared. A
9/// variant that no code path constructs is a promise the crate does
10/// not keep, and callers write dead match arms for it.
11#[derive(Debug, Clone, PartialEq, Error)]
12#[non_exhaustive]
13pub enum ControlError {
14 /// Entity kind differs from the requested projection.
15 #[error("expected {expected}, found {actual}")]
16 WrongEntityType {
17 /// Expected IFC entity.
18 expected: &'static str,
19 /// Actual IFC entity.
20 actual: String,
21 },
22 /// Required positional attribute is absent or null.
23 #[error("{entity} {id} is missing {attribute}")]
24 MissingAttribute {
25 /// Entity kind.
26 entity: &'static str,
27 /// Entity identifier.
28 id: EntityId,
29 /// Attribute name.
30 attribute: &'static str,
31 },
32 /// Requested entity is absent.
33 #[error("entity {id} does not exist")]
34 UnknownEntity {
35 /// Missing identifier.
36 id: EntityId,
37 },
38 /// Draft value is invalid before staging.
39 #[error("cannot author {entity}.{attribute}: {value}")]
40 AuthoringInvalid {
41 /// Entity kind.
42 entity: &'static str,
43 /// Attribute or rule.
44 attribute: &'static str,
45 /// Rejected value.
46 value: String,
47 },
48 /// The schema in use does not declare this entity.
49 ///
50 /// Authoring an entity the schema omits is a caller error, not a
51 /// silently-skipped attribute.
52 #[error("{schema} does not declare {entity}")]
53 UnsupportedEntity {
54 /// Schema name.
55 schema: String,
56 /// Entity that is not declared.
57 entity: &'static str,
58 },
59}
60
61/// Result alias for control operations.
62pub type ControlResult<T> = Result<T, ControlError>;