ricecoder_generation/
error.rs

1//! Error types for code generation
2
3use thiserror::Error;
4
5/// Errors that can occur during code generation
6#[derive(Debug, Error)]
7pub enum GenerationError {
8    /// Template not found
9    #[error("Template not found: {0}")]
10    TemplateNotFound(String),
11
12    /// Missing required placeholder
13    #[error("Missing required placeholder: {0}")]
14    MissingPlaceholder(String),
15
16    /// Invalid template syntax
17    #[error("Invalid template syntax at line {line}: {message}")]
18    InvalidSyntax {
19        /// Line number where syntax error occurred
20        line: usize,
21        /// Error message describing the syntax issue
22        message: String,
23    },
24
25    /// Template rendering error
26    #[error("Render error: {0}")]
27    RenderError(String),
28
29    /// Validation failed
30    #[error("Validation failed: {0}")]
31    ValidationFailed(String),
32
33    /// IO error
34    #[error("IO error: {0}")]
35    IoError(#[from] std::io::Error),
36
37    /// Serialization error
38    #[error("Serialization error: {0}")]
39    SerializationError(#[from] serde_json::Error),
40
41    /// Spec processing error
42    #[error("Spec error: {0}")]
43    SpecError(String),
44
45    /// Prompt building error
46    #[error("Prompt error: {0}")]
47    PromptError(String),
48
49    /// Code generation failed
50    #[error("Generation failed: {0}")]
51    GenerationFailed(String),
52
53    /// Validation error with details
54    #[error("Validation error in {file}:{line}: {message}")]
55    ValidationError {
56        /// File path where error occurred
57        file: String,
58        /// Line number where error occurred
59        line: usize,
60        /// Error message
61        message: String,
62    },
63
64    /// Linting error
65    #[error("Linting error: {0}")]
66    LintingError(String),
67
68    /// Type checking error
69    #[error("Type checking error: {0}")]
70    TypeCheckingError(String),
71
72    /// Syntax error
73    #[error("Syntax error: {0}")]
74    SyntaxError(String),
75
76    /// Write failed
77    #[error("Write failed: {0}")]
78    WriteFailed(String),
79
80    /// Rollback failed
81    #[error("Rollback failed: {0}")]
82    RollbackFailed(String),
83}