#[non_exhaustive]pub enum Error {
Show 54 variants
LspInitFailed {
phase: InitPhase,
cause: Box<Self>,
hint: Option<InitFailureHint>,
stderr: Option<StderrExcerpt>,
},
LspServerError {
code: i32,
message: String,
data: Option<Value>,
},
McpServerStart(Box<dyn Error + Send + Sync>),
TaskFailed {
task: BackgroundTask,
source: JoinError,
},
StdioCapture(StdioStream),
HttpBind {
addr: SocketAddr,
source: Error,
},
DocumentNotFound(PathBuf),
NoServerForLanguage {
language: LanguageId,
file: FileKey,
patterns: Arc<[FilePattern]>,
},
NoServerForTool {
language_id: LanguageId,
tool: ToolKind,
},
ServerFailedToStart(Box<ServerSpawnFailure>),
ServerInitializing {
server_id: ServerId,
},
ServerRestarted {
server_id: ServerId,
},
SymbolResolution(Box<SymbolResolutionData>),
UnknownServers {
unknown: Vec<ServerId>,
configured: Vec<ServerId>,
},
WorkspaceServersInitializing,
NoServerConfigured,
NoServerForWorkspaceTool {
tool: ToolKind,
},
ConfigNotFound(PathBuf),
ConfigInsideWorkspace {
path: PathBuf,
},
Config(ConfigError),
Io(Error),
Json(Error),
TomlDe(Error),
TomlSer(Error),
Timeout(Duration),
ServerSpawnFailed {
command: ServerCommand,
source: Error,
},
ServerNotFound {
command: ServerCommand,
source: Error,
},
LspProtocolError(RedactedText),
NoResolvableListenUris,
InvalidPositionInput(InvalidPosition),
InvalidRangeInput(InvalidRange),
InvalidHierarchyItemInput(InvalidHierarchyItem),
PositionBeyondDocument {
line: NonZeroU32,
last_line: NonZeroU32,
},
ResourceUri(ResourceUriError),
PathToUri(PathBuf),
ServerTerminated,
ShutdownTimeout,
ServerExitedDuringInit {
command: ServerCommand,
exit_code: Option<i32>,
hint: Option<InitFailureHint>,
stderr: Option<StderrExcerpt>,
},
ServerUnavailable {
server_id: ServerId,
retry_in: Duration,
},
InvalidToolParams(String),
InvalidClientPath(InvalidClientPath),
MalformedPath {
path: PathBuf,
source: Error,
},
FileIo {
path: PathBuf,
source: Error,
},
PathOutsideWorkspace(PathBuf),
NoWorkspaceRoots(PathBuf),
DocumentLimitExceeded {
current: usize,
max: NonZeroUsize,
},
SubscriptionLimitReached {
max: usize,
},
ListenStreamsExhausted {
max: usize,
},
ListenFilterTooLarge {
max: usize,
},
FileSizeLimitExceeded(SizeExceeded),
NotARegularFile(PathBuf),
AllServersFailedToInit {
failures: Vec<ServerSpawnFailure>,
},
CapabilityNotSupported {
server_id: ServerId,
capability: Capability,
},
WorkspaceIndexing {
server_id: ServerId,
elapsed_secs: u64,
},
}Expand description
The main error type for mcpls-core operations.
This enum is #[non_exhaustive]: downstream crates that match on it must
include a wildcard arm. New variants (such as Error::ServerInitializing)
can then be added without further breaking changes.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
LspInitFailed
LSP server failed to initialize.
Fields
cause: Box<Self>Why the step failed, so a timeout and a rejection by the server
stay distinguishable. Rendered by Display instead of being
exposed through source(), so the chain is not printed twice.
hint: Option<InitFailureHint>The likely cause and remedy, when one is known.
stderr: Option<StderrExcerpt>What the server wrote to stderr before failing, if anything.
LspServerError
LSP server returned an error response.
Fields
McpServerStart(Box<dyn Error + Send + Sync>)
The MCP server could not complete its handshake with the client.
TaskFailed
A background task panicked or was cancelled.
Fields
task: BackgroundTaskThe task that failed.
StdioCapture(StdioStream)
A standard stream of the spawned LSP server could not be captured.
HttpBind
The HTTP transport could not bind its listener.
Fields
addr: SocketAddrAddress the listener was asked to bind.
DocumentNotFound(PathBuf)
Document was not found or could not be opened.
NoServerForLanguage
No LSP server configured for the given language.
Fields
language: LanguageIdThe language detected for the file.
file: FileKeyWhat identifies the file to the language map: its extension, its
extensionless name, or FileKey::Unmappable.
patterns: Arc<[FilePattern]>The file_patterns configured across all servers, so the error can
show what was available to map the extension.
NoServerForTool
A server is configured for the language, but no server claims this
specific tool (either no server lists it in handles and there is no
catch-all, or the server that claimed it failed to spawn with no live
catch-all to rebind to).
Fields
language_id: LanguageIdLanguage ID the request was for.
ServerFailedToStart(Box<ServerSpawnFailure>)
The server configured for this request failed to start and, because startup failures are never retried, will not become available until mcpls is restarted.
Boxed to keep Error small.
ServerInitializing
LSP server for the language is configured but still initializing.
ServerRestarted
The server was restarted on request while this call was in flight or being routed; the request never reached the replacement.
SymbolResolution(Box<SymbolResolutionData>)
A symbol name could not be resolved to exactly one position.
Boxed to keep Error small.
UnknownServers
A restart request named servers that are not configured.
Fields
WorkspaceServersInitializing
A workspace-wide tool (one with no file to resolve a language from,
e.g. workspace_symbol_search) could not be routed because at least
one expected LSP server has not registered yet. Unlike
Error::ServerInitializing, resolution never narrowed down to a
single candidate server, so no server_id is available.
NoServerConfigured
No LSP server is currently configured.
NoServerForWorkspaceTool
At least one server is configured somewhere in the workspace, but
none of them claims a workspace-wide tool that has no file to
resolve a language from (e.g. workspace_symbol_search). The
language-less counterpart of Error::NoServerForTool.
ConfigNotFound(PathBuf)
Configuration file not found.
ConfigInsideWorkspace
Untrusted-workspace mode refused a config file that lies inside the workspace or the current directory, because the analyzed checkout controls it. A startup error; never reaches a tool response.
Config(ConfigError)
Invalid configuration.
Io(Error)
I/O error; displays the OS text once, with no prefix.
Json(Error)
JSON serialization/deserialization error.
TomlDe(Error)
TOML deserialization error.
TomlSer(Error)
TOML serialization error.
Timeout(Duration)
Request timeout, carrying the elapsed limit.
ServerSpawnFailed
LSP server failed to spawn.
ServerNotFound
LSP server executable was not found.
Distinct from Error::ServerSpawnFailed so the message can carry
PATH and install guidance.
LspProtocolError(RedactedText)
LSP protocol error during message parsing.
NoResolvableListenUris
None of the resource URIs a subscriptions/listen request named
resolves inside the workspace.
InvalidPositionInput(InvalidPosition)
A client-supplied position is out of bounds.
InvalidRangeInput(InvalidRange)
A client-supplied range is malformed or too large.
InvalidHierarchyItemInput(InvalidHierarchyItem)
A client-supplied hierarchy item has an invalid range.
PositionBeyondDocument
A client-supplied line lies beyond the end of the tracked document.
Only the line is checked: an LSP server clamps a character past the
end of its line to the line length (LSP 3.17, Position), so such a
character is forwarded unchanged.
Fields
line: NonZeroU32The 1-based line the client supplied.
last_line: NonZeroU32The 1-based number of the document’s last line.
ResourceUri(ResourceUriError)
A client-supplied lsp-diagnostics:// resource URI was rejected.
PathToUri(PathBuf)
A path mcpls itself derived could not be represented as a URI.
ServerTerminated
Server process terminated unexpectedly.
ShutdownTimeout
LSP server shutdown did not complete before its deadline.
ServerExitedDuringInit
LSP server process exited before completing the initialize
handshake.
Fields
command: ServerCommandCommand that was spawned.
hint: Option<InitFailureHint>The likely cause and remedy, when one is known.
stderr: Option<StderrExcerpt>What the server wrote to stderr before exiting, if anything.
A crashed server could not be automatically respawned.
Distinct from Self::ServerTerminated so a caller (or a log
reader) can tell “the connection just died” apart from “mcpls tried
to bring it back and could not” – it is crash-looping and is being
backed off.
InvalidToolParams(String)
Invalid tool parameters provided.
InvalidClientPath(InvalidClientPath)
A client-supplied file path is empty or contains a NUL byte.
MalformedPath
A client-supplied file path is malformed for the filesystem: it runs through a regular file, or has an invalid or over-long name.
Produced only while validating the client path
(WorkspaceRoots::validate); the same IO kinds raised later, while
reading or opening an already validated file, stay Error::FileIo
because there they are environmental.
FileIo
File I/O error occurred.
See Error::mcp_error_kind for the JSON-RPC classification: a
source.kind() == ErrorKind::NotFound failure – whether path was
freshly supplied in this request or was tracked from an earlier one
and has since been deleted/moved on disk – is caller-fault; any
other IO failure is not.
PathOutsideWorkspace(PathBuf)
Path is outside allowed workspace boundaries.
NoWorkspaceRoots(PathBuf)
No workspace roots are configured, so path-taking operations are rejected outright rather than allowed unrestricted (fail closed).
DocumentLimitExceeded
Document limit exceeded.
SubscriptionLimitReached
Resource-subscription limit exceeded for the session.
See Error::mcp_error_kind for the JSON-RPC classification: same
shape as Self::DocumentLimitExceeded – fires on aggregate
per-session tracker state, not this request’s params – so it is
classified the same way, not InvalidParams.
ListenStreamsExhausted
Too many concurrent subscriptions/listen streams are open.
Transient: a stream closing frees a slot, so it is classified as
retryable (see Error::mcp_error_kind).
ListenFilterTooLarge
A subscriptions/listen request asked for more resource URIs than a
single stream may watch.
FileSizeLimitExceeded(SizeExceeded)
File size limit exceeded.
NotARegularFile(PathBuf)
Path exists but does not refer to a regular file (e.g. a FIFO or a character/block device).
mcpls refuses to read such paths: their reported size does not bound
how much data reading them could produce, and opening some of them
for reading can block indefinitely waiting for a peer. A Unix domain
socket special file is not covered by this variant – open(2) on
one fails outright (ENXIO) before the file-type check that produces
this error ever runs, so it surfaces as Self::FileIo from a
document read and as Self::Io from the config loader.
AllServersFailedToInit
All configured LSP servers failed to initialize.
Fields
failures: Vec<ServerSpawnFailure>Details of each failure.
CapabilityNotSupported
The server routed for this request does not advertise support for the
requested LSP capability (e.g. no renameProvider in its
ServerCapabilities).
Fields
capability: CapabilityThe missing LSP capability, naming the ServerCapabilities field
mcpls checked.
WorkspaceIndexing
The routed server has an active signal indicating its initial
workspace-load/indexing phase is still in progress, and the bounded
wait for it to finish elapsed before it completed. Returned instead
of an unqualified empty/null result so a caller cannot mistake
“index not ready yet” for “this position/symbol genuinely has
nothing here”.
Implementations§
Source§impl Error
impl Error
Sourcepub fn mcp_error_kind(&self) -> McpErrorKind
pub fn mcp_error_kind(&self) -> McpErrorKind
Classify this error for JSON-RPC error-code mapping.
Matched exhaustively with no wildcard arm: a newly added Error
variant must be given an explicit classification here instead of
silently defaulting to McpErrorKind::Internal.
§Examples
use mcpls_core::config::ServerId;
use mcpls_core::error::{Error, McpErrorKind};
let err = Error::WorkspaceIndexing {
server_id: ServerId::from_static("rust"),
elapsed_secs: 30,
};
let McpErrorKind::Retryable(data) = err.mcp_error_kind() else {
panic!("expected a retryable classification");
};
assert_eq!(data.code(), mcpls_core::error::WORKSPACE_INDEXING_ERROR_CODE);Trait Implementations§
Source§impl Error for Error
impl Error for Error
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()