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