pub enum SdkError {
Show 19 variants
CliNotFound {
searched_paths: String,
},
ConnectionError(String),
ProcessError(Error),
MessageParseError {
error: String,
raw: String,
},
JsonError(Error),
CliJsonDecodeError {
line: String,
original_error: Error,
},
TransportError(String),
Timeout {
seconds: u64,
},
SessionNotFound(String),
ConfigError(String),
ControlRequestError(String),
UnexpectedResponse {
expected: String,
actual: String,
},
CliError {
message: String,
code: Option<String>,
},
ChannelSendError,
ChannelClosed,
InvalidState {
message: String,
},
ProcessExited {
code: Option<i32>,
},
UnexpectedStreamEnd,
NotSupported {
feature: String,
},
}Expand description
Main error type for the Claude Code SDK
Variants§
CliNotFound
Claude CLI executable was not found
ConnectionError(String)
Failed to connect to Claude CLI
ProcessError(Error)
Process-related errors
MessageParseError
Failed to parse a message
JsonError(Error)
JSON serialization/deserialization errors
CliJsonDecodeError
CLI JSON decode error
TransportError(String)
Transport layer errors
Timeout
Timeout waiting for response
SessionNotFound(String)
Session not found
ConfigError(String)
Invalid configuration
ControlRequestError(String)
Control request failed
UnexpectedResponse
Unexpected response type
CliError
CLI returned an error
ChannelSendError
Channel send error
ChannelClosed
Channel receive error
InvalidState
Invalid state transition
ProcessExited
Process exited unexpectedly
UnexpectedStreamEnd
Stream ended unexpectedly
NotSupported
Feature not supported
Implementations§
Source§impl SdkError
impl SdkError
Sourcepub fn parse_error(error: impl Into<String>, raw: impl Into<String>) -> Self
pub fn parse_error(error: impl Into<String>, raw: impl Into<String>) -> Self
Create a new MessageParseError
Sourcepub fn unexpected_response(
expected: impl Into<String>,
actual: impl Into<String>,
) -> Self
pub fn unexpected_response( expected: impl Into<String>, actual: impl Into<String>, ) -> Self
Create a new UnexpectedResponse error
Sourcepub fn cli_error(message: impl Into<String>, code: Option<String>) -> Self
pub fn cli_error(message: impl Into<String>, code: Option<String>) -> Self
Create a new CliError
Sourcepub fn invalid_state(message: impl Into<String>) -> Self
pub fn invalid_state(message: impl Into<String>) -> Self
Create a new InvalidState error
Sourcepub fn is_recoverable(&self) -> bool
pub fn is_recoverable(&self) -> bool
Check if the error is recoverable
Sourcepub fn is_config_error(&self) -> bool
pub fn is_config_error(&self) -> bool
Check if the error is a configuration issue
Trait Implementations§
Source§impl Error for SdkError
impl Error for SdkError
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()
Auto Trait Implementations§
impl Freeze for SdkError
impl !RefUnwindSafe for SdkError
impl Send for SdkError
impl Sync for SdkError
impl Unpin for SdkError
impl !UnwindSafe for SdkError
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> 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> 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