use crate::value::EntityId;
use thiserror::Error;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum ModelError {
#[error("io error: {0}")]
Io(String),
#[error("not a {expected} file: {detail}")]
WrongFormat {
expected: &'static str,
detail: String,
},
#[error("syntax error at byte {offset}: {detail}")]
Syntax {
offset: usize,
detail: String,
},
#[error("entity {from} references missing entity {to}")]
DanglingReference {
from: EntityId,
to: EntityId,
},
#[error("duplicate entity id {0}")]
DuplicateId(EntityId),
#[error("write error: {0}")]
Write(String),
}
pub type ModelResult<T> = Result<T, ModelError>;