formualizer_sheetport/
error.rs1use crate::validation::ConstraintViolation;
2use formualizer_common::ExcelError;
3use formualizer_workbook::error::IoError;
4use sheetport_spec::{ManifestIssue, ValidationError};
5use thiserror::Error;
6
7#[derive(Debug, Error)]
9pub enum SheetPortError {
10 #[error("manifest validation failed")]
12 InvalidManifest { issues: Vec<ManifestIssue> },
13 #[error("unsupported selector for port `{port}`: {reason}")]
15 UnsupportedSelector { port: String, reason: String },
16 #[error("invalid reference `{reference}` in port `{port}`: {details}")]
18 InvalidReference {
19 port: String,
20 reference: String,
21 details: String,
22 },
23 #[error("sheet `{sheet}` referenced by port `{port}` was not found in the workbook")]
25 MissingSheet { port: String, sheet: String },
26 #[error("invariant violation for port `{port}`: {message}")]
28 InvariantViolation { port: String, message: String },
29 #[error("value did not satisfy manifest constraints")]
31 ConstraintViolation {
32 violations: Vec<ConstraintViolation>,
33 },
34 #[error("engine error: {source}")]
36 Engine {
37 #[from]
38 source: ExcelError,
39 },
40 #[error("workbook error: {source}")]
42 Workbook {
43 #[from]
44 source: IoError,
45 },
46}
47
48impl From<ValidationError> for SheetPortError {
49 fn from(err: ValidationError) -> Self {
50 SheetPortError::InvalidManifest {
51 issues: err.issues().to_vec(),
52 }
53 }
54}