1use thiserror::Error;
4
5pub type Result<T> = std::result::Result<T, MetisError>;
6
7#[derive(Debug, Error)]
8pub enum MetisError {
9 #[error("Database error: {0}")]
10 Database(#[from] diesel::result::Error),
11
12 #[error("Connection error: {0}")]
13 Connection(#[from] diesel::ConnectionError),
14
15 #[error("IO error: {0}")]
16 Io(#[from] std::io::Error),
17
18 #[error("JSON serialization error: {0}")]
19 Json(#[from] serde_json::Error),
20
21 #[error("YAML parsing error: {0}")]
22 Yaml(#[from] serde_yaml::Error),
23
24 #[error("Document not found: {id}")]
25 DocumentNotFound { id: String },
26
27 #[error("Invalid document type: {document_type}")]
28 InvalidDocumentType { document_type: String },
29
30 #[error("Invalid phase transition from {from} to {to} for document type {doc_type}")]
31 InvalidPhaseTransition {
32 from: String,
33 to: String,
34 doc_type: String,
35 },
36
37 #[error("Missing required field: {field}")]
38 MissingRequiredField { field: String },
39
40 #[error("Template not found: {template}")]
41 TemplateNotFound { template: String },
42
43 #[error("Validation failed: {message}")]
44 ValidationFailed { message: String },
45
46 #[error("Exit criteria not met: {missing_count} of {total_count} criteria incomplete")]
47 ExitCriteriaNotMet {
48 missing_count: usize,
49 total_count: usize,
50 },
51
52 #[error("Not found: {0}")]
53 NotFound(String),
54
55 #[error("Invalid document: {0}")]
56 InvalidDocument(String),
57
58 #[error("File system error: {0}")]
59 FileSystem(String),
60
61 #[error("Document validation error: {0}")]
62 DocumentValidation(#[from] crate::domain::documents::traits::DocumentValidationError),
63}