Skip to main content

mcp_servers/lsp/
error.rs

1//! LSP-specific error types
2
3use aether_lspd::{ClientError, UriError};
4use thiserror::Error;
5
6#[doc = include_str!("../docs/lsp_error.md")]
7#[derive(Debug, Error)]
8pub enum LspError {
9    /// I/O error (e.g., reading a file)
10    #[error("I/O error: {0}")]
11    Io(#[from] std::io::Error),
12
13    /// LSP client / daemon communication error
14    #[error(transparent)]
15    Client(#[from] ClientError),
16
17    /// The language server is configured but unavailable.
18    #[error("Language server unavailable: {0}")]
19    ServerUnavailable(String),
20
21    /// No language server is configured for the requested language.
22    #[error("No LSP configured for {0}")]
23    UnsupportedLanguage(String),
24
25    /// The requested path cannot be represented as a file URI.
26    #[error("Invalid path: {0}")]
27    InvalidPath(String),
28
29    /// The requested symbol could not be found.
30    #[error("Symbol not found: {0}")]
31    SymbolNotFound(String),
32
33    /// The requested source position is invalid.
34    #[error("Invalid source position: {0}")]
35    InvalidPosition(String),
36
37    /// An LSP edit produced an invalid or unsupported change.
38    #[error("Invalid edit: {0}")]
39    InvalidEdit(String),
40}
41
42impl From<UriError> for LspError {
43    fn from(error: UriError) -> Self {
44        Self::InvalidPath(error.to_string())
45    }
46}