use thiserror::Error;
#[derive(Debug, Error)]
pub enum RustMethError {
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
#[error("Integer parse error: {0}")]
ParseInt(#[from] std::num::ParseIntError),
#[error("No Content-Length header in LSP response")]
NoContentLength,
#[error("recv_until: exhausted {limit} messages without a match")]
RecvExhausted {
limit: usize,
},
#[error("Unexpected completion response shape: {0}")]
UnexpectedResponseShape(String),
#[error(
"rust-analyzer not found.\nInstall it with: rustup component add rust-analyzer\nor ensure it is on your PATH."
)]
RustAnalyzerNotFound,
#[error("child process stdin was not captured (spawn with Stdio::piped())")]
MissingStdin,
#[error("child process stdout was not captured (spawn with Stdio::piped())")]
MissingStdout,
}
pub type Result<T> = std::result::Result<T, RustMethError>;