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