ricecoder_ide/
error.rs

1//! Error types for IDE integration
2
3use thiserror::Error;
4
5/// IDE Integration Error
6#[derive(Debug, Error)]
7pub enum IdeError {
8    /// Configuration error
9    #[error("Configuration error: {0}")]
10    ConfigError(String),
11
12    /// Configuration validation error
13    #[error("Configuration validation error: {0}")]
14    ConfigValidationError(String),
15
16    /// Path resolution error
17    #[error("Path resolution error: {0}")]
18    PathResolutionError(String),
19
20    /// LSP server error
21    #[error("LSP server error: {0}")]
22    LspError(String),
23
24    /// Provider error
25    #[error("Provider error: {0}")]
26    ProviderError(String),
27
28    /// IDE communication error
29    #[error("IDE communication error: {0}")]
30    CommunicationError(String),
31
32    /// Timeout error
33    #[error("Operation timeout after {0}ms")]
34    Timeout(u64),
35
36    /// Serialization error
37    #[error("Serialization error: {0}")]
38    SerializationError(#[from] serde_json::Error),
39
40    /// YAML parsing error
41    #[error("YAML parsing error: {0}")]
42    YamlError(#[from] serde_yaml::Error),
43
44    /// JSON Schema validation error
45    #[error("JSON Schema validation error: {0}")]
46    SchemaValidationError(String),
47
48    /// IO error
49    #[error("IO error: {0}")]
50    IoError(#[from] std::io::Error),
51
52    /// Generic error
53    #[error("{0}")]
54    Other(String),
55}
56
57impl IdeError {
58    /// Create a configuration error with remediation steps
59    pub fn config_error(message: impl Into<String>) -> Self {
60        IdeError::ConfigError(message.into())
61    }
62
63    /// Create a configuration validation error with remediation steps
64    pub fn config_validation_error(message: impl Into<String>) -> Self {
65        IdeError::ConfigValidationError(message.into())
66    }
67
68    /// Create a path resolution error
69    pub fn path_resolution_error(message: impl Into<String>) -> Self {
70        IdeError::PathResolutionError(message.into())
71    }
72
73    /// Create an LSP error
74    pub fn lsp_error(message: impl Into<String>) -> Self {
75        IdeError::LspError(message.into())
76    }
77
78    /// Create a provider error
79    pub fn provider_error(message: impl Into<String>) -> Self {
80        IdeError::ProviderError(message.into())
81    }
82
83    /// Create a communication error
84    pub fn communication_error(message: impl Into<String>) -> Self {
85        IdeError::CommunicationError(message.into())
86    }
87
88    /// Create a timeout error
89    pub fn timeout(ms: u64) -> Self {
90        IdeError::Timeout(ms)
91    }
92
93    /// Create a schema validation error
94    pub fn schema_validation_error(message: impl Into<String>) -> Self {
95        IdeError::SchemaValidationError(message.into())
96    }
97
98    /// Create a generic error
99    pub fn other(message: impl Into<String>) -> Self {
100        IdeError::Other(message.into())
101    }
102}
103
104/// Result type for IDE integration operations
105pub type IdeResult<T> = Result<T, IdeError>;