1use thiserror::Error;
4
5#[derive(Debug, Error)]
7pub enum IdeError {
8 #[error("Configuration error: {0}")]
10 ConfigError(String),
11
12 #[error("Configuration validation error: {0}")]
14 ConfigValidationError(String),
15
16 #[error("Path resolution error: {0}")]
18 PathResolutionError(String),
19
20 #[error("LSP server error: {0}")]
22 LspError(String),
23
24 #[error("Provider error: {0}")]
26 ProviderError(String),
27
28 #[error("IDE communication error: {0}")]
30 CommunicationError(String),
31
32 #[error("Operation timeout after {0}ms")]
34 Timeout(u64),
35
36 #[error("Serialization error: {0}")]
38 SerializationError(#[from] serde_json::Error),
39
40 #[error("YAML parsing error: {0}")]
42 YamlError(#[from] serde_yaml::Error),
43
44 #[error("JSON Schema validation error: {0}")]
46 SchemaValidationError(String),
47
48 #[error("IO error: {0}")]
50 IoError(#[from] std::io::Error),
51
52 #[error("{0}")]
54 Other(String),
55}
56
57impl IdeError {
58 pub fn config_error(message: impl Into<String>) -> Self {
60 IdeError::ConfigError(message.into())
61 }
62
63 pub fn config_validation_error(message: impl Into<String>) -> Self {
65 IdeError::ConfigValidationError(message.into())
66 }
67
68 pub fn path_resolution_error(message: impl Into<String>) -> Self {
70 IdeError::PathResolutionError(message.into())
71 }
72
73 pub fn lsp_error(message: impl Into<String>) -> Self {
75 IdeError::LspError(message.into())
76 }
77
78 pub fn provider_error(message: impl Into<String>) -> Self {
80 IdeError::ProviderError(message.into())
81 }
82
83 pub fn communication_error(message: impl Into<String>) -> Self {
85 IdeError::CommunicationError(message.into())
86 }
87
88 pub fn timeout(ms: u64) -> Self {
90 IdeError::Timeout(ms)
91 }
92
93 pub fn schema_validation_error(message: impl Into<String>) -> Self {
95 IdeError::SchemaValidationError(message.into())
96 }
97
98 pub fn other(message: impl Into<String>) -> Self {
100 IdeError::Other(message.into())
101 }
102}
103
104pub type IdeResult<T> = Result<T, IdeError>;