1use serde::{Deserialize, Serialize};
4use thiserror::Error;
5
6#[derive(Error, Debug, Clone, Serialize, Deserialize)]
8pub enum BuildError {
9    #[error("Invalid format in {field}: {message}")]
11    InvalidFormat {
12        field: String,
14        message: String,
16    },
17
18    #[error("Missing required field: {field}")]
20    MissingRequired {
21        field: String,
23    },
24
25    #[error("Invalid reference: {reference}")]
27    InvalidReference {
28        reference: String,
30    },
31
32    #[error("Validation failed: {}", errors.join(", "))]
34    ValidationFailed {
35        errors: Vec<String>,
37    },
38
39    #[error("IO error: {0}")]
41    Io(String),
42
43    #[error("Serialization error: {0}")]
45    Serialization(String),
46
47    #[error("XML generation error: {0}")]
49    XmlGeneration(String),
50
51    #[error("Determinism verification failed: {message}")]
53    DeterminismFailed {
54        message: String,
56    },
57
58    #[error("Determinism guarantee violated: {guarantee} - {details}")]
60    DeterminismGuaranteeViolated {
61        guarantee: String,
63        details: String,
65    },
66
67    #[error("Validation error: {0}")]
69    Validation(String),
70
71    #[error("Parallel processing error: {0}")]
73    Parallel(String),
74
75    #[error("Security violation: {0}")]
77    Security(String),
78
79    #[error("Input sanitization failed: {0}")]
81    InputSanitization(String),
82
83    #[error("{0}")]
85    Other(String),
86}
87
88impl From<std::io::Error> for BuildError {
89    fn from(err: std::io::Error) -> Self {
90        BuildError::Io(err.to_string())
91    }
92}
93
94impl From<serde_json::Error> for BuildError {
95    fn from(err: serde_json::Error) -> Self {
96        BuildError::Serialization(err.to_string())
97    }
98}
99
100impl From<quick_xml::Error> for BuildError {
101    fn from(err: quick_xml::Error) -> Self {
102        BuildError::XmlGeneration(err.to_string())
103    }
104}
105
106#[derive(Debug, Clone, Serialize, Deserialize)]
108pub struct BuildWarning {
109    pub code: String,
111    pub message: String,
113    pub location: Option<String>,
115}