Skip to main content

synwire_dap/
error.rs

1//! Error types for the DAP integration.
2
3use thiserror::Error;
4
5/// Errors that can occur during DAP operations.
6#[derive(Debug, Error)]
7#[non_exhaustive]
8pub enum DapError {
9    /// Debug adapter process is not running.
10    #[error("debug adapter not running")]
11    NotRunning,
12
13    /// Debug adapter has not reached a ready state.
14    #[error("debug adapter not ready (state: {state})")]
15    NotReady {
16        /// Current state description.
17        state: String,
18    },
19
20    /// A DAP request returned an error response.
21    #[error("DAP request failed: {command}: {message}")]
22    RequestFailed {
23        /// The DAP command that failed.
24        command: String,
25        /// Error message from the adapter.
26        message: String,
27    },
28
29    /// The debug adapter binary was not found on `PATH`.
30    #[error("adapter binary not found: {binary}")]
31    BinaryNotFound {
32        /// Name of the binary that was not found.
33        binary: String,
34    },
35
36    /// Initialization handshake failed.
37    #[error("initialization failed: {0}")]
38    InitializationFailed(String),
39
40    /// Transport-level communication error.
41    #[error("transport error: {0}")]
42    Transport(String),
43
44    /// JSON serialization or deserialization error.
45    #[error("serialization error: {0}")]
46    Serialization(#[from] serde_json::Error),
47
48    /// Underlying I/O error.
49    #[error("IO error: {0}")]
50    Io(#[from] std::io::Error),
51
52    /// Content-Length codec error.
53    #[error("codec error: {0}")]
54    Codec(String),
55
56    /// No active debug session to operate on.
57    #[error("no active debug session")]
58    NoActiveSession,
59
60    /// Timed out waiting for an adapter response.
61    #[error("timeout waiting for response")]
62    Timeout,
63}