pub enum ClaudeError {
Show 17 variants
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),
SessionNotFound(String),
SessionComplete(String),
MaxSessionsReached(usize),
InvalidAgentConfiguration(String),
PromptTemplateError {
template: String,
message: 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
SessionNotFound(String)
Agent session not found
SessionComplete(String)
Agent session already complete (cannot send more messages)
MaxSessionsReached(usize)
Maximum active sessions limit reached
InvalidAgentConfiguration(String)
Invalid agent session configuration
PromptTemplateError
Failed to render prompt template
Implementations§
Source§impl ClaudeError
impl ClaudeError
Sourcepub fn cli_not_found() -> Self
pub fn cli_not_found() -> Self
Create a CLI not found error
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
Sourcepub fn session_not_found(session_id: impl Into<String>) -> Self
pub fn session_not_found(session_id: impl Into<String>) -> Self
Create a session not found error
Sourcepub fn session_complete(session_id: impl Into<String>) -> Self
pub fn session_complete(session_id: impl Into<String>) -> Self
Create a session complete error
Sourcepub fn max_sessions_reached(max: usize) -> Self
pub fn max_sessions_reached(max: usize) -> Self
Create a max sessions error
Sourcepub fn invalid_agent_config(msg: impl Into<String>) -> Self
pub fn invalid_agent_config(msg: impl Into<String>) -> Self
Create an invalid agent 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)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<ClaudeError> for McpError
impl From<ClaudeError> for McpError
Source§fn from(err: ClaudeError) -> Self
fn from(err: ClaudeError) -> Self
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.