pub enum Error {
CliNotFound {
binary: String,
},
CwdNotFound {
path: String,
},
Process {
exit_code: Option<i32>,
stderr: String,
},
Connection {
reason: String,
},
JsonDecode {
line: u64,
source: Error,
},
MessageParse {
reason: String,
data: Option<Value>,
},
Encode {
context: String,
source: Error,
},
Io(Error),
}Expand description
All errors surfaced by forge-sdk.
Variants§
CliNotFound
The claude binary (or a custom replacement) was not found on PATH.
Wraps the CLI’s CLINotFoundError.
CwdNotFound
The subprocess’s working directory does not exist.
Separate from Error::CliNotFound because a spawn that
cannot enter its cwd fails with the same ENOENT as one that
cannot find the binary.
Process
The subprocess exited with a non-zero status or was terminated by a signal.
Wraps the CLI’s ProcessError.
Fields
Connection
Could not establish or maintain the stdio connection to the subprocess.
Wraps the CLI’s CLIConnectionError.
JsonDecode
A line of stream-json from the subprocess could not be parsed as JSON.
Wraps the CLI’s CLIJSONDecodeError.
Fields
MessageParse
A stream-json message parsed as JSON but did not match any known message schema.
Wraps the CLI’s MessageParseError (_errors.py:48-55), including
the optional data field that carries the offending payload when
one is available. the CLI reads this as a dict[str, Any] | None;
forge-sdk types it as Option<serde_json::Value> so callers
inspecting the failure can recover the decoded JSON without
re-parsing the error message.
Fields
Encode
Forge-sdk failed to JSON-encode a local payload (initialize
envelope, control_request body, hook response, session
mutation entry, etc.). Distinct from
Error::MessageParse, which is for parse failures on
data the CLI sent us - Encode is when we couldn’t
serialise something locally and the bug is on the SDK or
caller side, not the CLI’s. context names what we were
trying to encode (e.g. “agents map”, “initialize body”,
“user prompt”).
Io(Error)
Wrapping std::io::Error for convenience.
Implementations§
Source§impl Error
impl Error
Sourcepub fn message_parse(reason: impl Into<String>) -> Self
pub fn message_parse(reason: impl Into<String>) -> Self
Construct a Error::MessageParse carrying only a reason string
(most call sites). Equivalent to the struct-literal form with
data: None.
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()