use ifc_model::EntityId;
use thiserror::Error;
#[derive(Debug, Clone, PartialEq, Eq, Error)]
#[non_exhaustive]
pub enum TabularError {
#[error("{entity}: row {row} has {found} cells, the first row has {expected}")]
RaggedRow {
entity: &'static str,
row: usize,
expected: usize,
found: usize,
},
#[error("{entity}: {found} heading rows, at most one is allowed")]
TooManyHeadings {
entity: &'static str,
found: usize,
},
#[error("{entity}.{attribute} requires at least one entry")]
EmptyList {
entity: &'static str,
attribute: &'static str,
},
#[error("{entity}.{attribute} requires a non-blank value")]
BlankRequired {
entity: &'static str,
attribute: &'static str,
},
#[error("{entity}.{attribute} requires a finite value")]
NotFinite {
entity: &'static str,
attribute: &'static str,
},
}
pub type TabularResult<T> = Result<T, TabularError>;
#[derive(Debug, Clone, PartialEq, Eq, Error)]
#[non_exhaustive]
pub enum TabularReadError {
#[error("entity {id} does not exist")]
UnknownEntity {
id: EntityId,
},
#[error("{id} is {actual}, expected {expected}")]
WrongEntityType {
id: EntityId,
expected: &'static str,
actual: String,
},
#[error("{schema} is not supported; tabular reads decode IFC4 and IFC4X3")]
UnsupportedSchema {
schema: String,
},
}
pub type TabularReadResult<T> = Result<T, TabularReadError>;