pub enum ClaudeError {
CliNotFound(String),
Connection(String),
Process {
message: String,
exit_code: i32,
stderr: Option<String>,
},
JsonDecode(Error),
MessageParse {
message: String,
data: Option<Value>,
},
Transport(String),
ControlProtocol(String),
Hook(String),
Mcp(String),
Io(Error),
Timeout(String),
InvalidConfig(String),
}Expand description
Main error type for the Claude Agent SDK
Variants§
CliNotFound(String)
Claude Code CLI not found or not installed
Connection(String)
Connection error when communicating with Claude Code
Process
Process execution error with exit code and stderr
Fields
JsonDecode(Error)
JSON decode error when parsing CLI output
MessageParse
Message parse error with optional raw data
Transport(String)
Transport layer error
ControlProtocol(String)
Control protocol error
Hook(String)
Hook execution error
Mcp(String)
MCP (Model Context Protocol) error
Io(Error)
I/O error
Timeout(String)
Timeout error
InvalidConfig(String)
Invalid configuration
Implementations§
Source§impl ClaudeError
impl ClaudeError
Sourcepub fn cli_not_found() -> Self
pub fn cli_not_found() -> Self
Create a CLI not found error with a helpful message
Sourcepub fn connection(msg: impl Into<String>) -> Self
pub fn connection(msg: impl Into<String>) -> Self
Create a connection error
Sourcepub fn process(
msg: impl Into<String>,
exit_code: i32,
stderr: Option<String>,
) -> Self
pub fn process( msg: impl Into<String>, exit_code: i32, stderr: Option<String>, ) -> Self
Create a process error
Sourcepub fn message_parse(msg: impl Into<String>, data: Option<Value>) -> Self
pub fn message_parse(msg: impl Into<String>, data: Option<Value>) -> Self
Create a message parse error
Sourcepub fn control_protocol(msg: impl Into<String>) -> Self
pub fn control_protocol(msg: impl Into<String>) -> Self
Create a control protocol error
Sourcepub fn protocol_error(msg: impl Into<String>) -> Self
pub fn protocol_error(msg: impl Into<String>) -> Self
Alias for control_protocol - used by protocol handler
Sourcepub fn json_encode(msg: impl Into<String>) -> Self
pub fn json_encode(msg: impl Into<String>) -> Self
Create a JSON encode error
Sourcepub fn json_decode(msg: impl Into<String>) -> Self
pub fn json_decode(msg: impl Into<String>) -> Self
Create a JSON decode error from string
Sourcepub fn invalid_config(msg: impl Into<String>) -> Self
pub fn invalid_config(msg: impl Into<String>) -> Self
Create an invalid configuration error
Trait Implementations§
Source§impl Debug for ClaudeError
impl Debug for ClaudeError
Source§impl Display for ClaudeError
impl Display for ClaudeError
Source§impl Error for ClaudeError
impl Error for ClaudeError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§impl From<Error> for ClaudeError
impl From<Error> for ClaudeError
Auto Trait Implementations§
impl Freeze for ClaudeError
impl !RefUnwindSafe for ClaudeError
impl Send for ClaudeError
impl Sync for ClaudeError
impl Unpin for ClaudeError
impl !UnwindSafe for ClaudeError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more