#[non_exhaustive]pub enum Error {
Show 24 variants
Api {
message: String,
status: Option<u16>,
error_type: Option<String>,
},
Auth {
message: String,
},
Network(Error),
Json(Error),
Parse(String),
Tool(ToolError),
Config(String),
Io(Error),
RateLimit {
retry_after: Option<Duration>,
},
ContextOverflow {
current: usize,
max: usize,
},
Timeout(Duration),
TokenValidation(TokenValidationError),
InvalidRequest(String),
Stream(String),
Env(VarError),
NotSupported {
provider: &'static str,
operation: &'static str,
},
Permission(String),
BudgetExceeded {
used: f64,
limit: f64,
},
ModelOverloaded {
model: String,
},
Session(String),
Mcp(String),
ResourceExhausted(String),
HookFailed {
hook: String,
reason: String,
},
HookTimeout {
hook: String,
duration_secs: u64,
},
}Expand description
Error type for claude-agent operations.
All errors include actionable context to help diagnose and resolve issues.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Api
API returned an error response.
Auth
Authentication failed.
Network(Error)
Network connectivity or request failed.
Json(Error)
JSON serialization or deserialization failed.
Parse(String)
Failed to parse response or configuration.
Tool(ToolError)
Tool execution failed.
Config(String)
Invalid or missing configuration.
Io(Error)
File system operation failed.
RateLimit
API rate limit exceeded.
ContextOverflow
Context window token limit exceeded.
Timeout(Duration)
Operation exceeded timeout.
TokenValidation(TokenValidationError)
Token configuration validation failed.
InvalidRequest(String)
Request parameters are invalid.
Stream(String)
Streaming response error.
Env(VarError)
Required environment variable missing or invalid.
NotSupported
Operation not supported by the current provider.
Permission(String)
Operation blocked by permission policy.
BudgetExceeded
Budget limit exceeded.
ModelOverloaded
Model is temporarily overloaded.
Session(String)
Session operation failed.
Mcp(String)
MCP server communication failed.
ResourceExhausted(String)
System resource limit reached (memory, processes, etc.)
HookFailed
Hook execution failed (blockable hooks only).
HookTimeout
Hook timed out (blockable hooks only).
Implementations§
Source§impl Error
impl Error
pub fn auth(message: impl Into<String>) -> Self
pub fn category(&self) -> ErrorCategory
pub fn is_configuration_error(&self) -> bool
pub fn is_resource_limit(&self) -> bool
pub fn is_retryable(&self) -> bool
pub fn is_overloaded(&self) -> bool
pub fn status_code(&self) -> Option<u16>
pub fn retry_after(&self) -> Option<Duration>
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
Source§impl From<ConfigError> for Error
impl From<ConfigError> for Error
Source§fn from(err: ConfigError) -> Self
fn from(err: ConfigError) -> Self
Source§impl From<ContextError> for Error
impl From<ContextError> for Error
Source§fn from(err: ContextError) -> Self
fn from(err: ContextError) -> Self
Source§impl From<SandboxError> for Error
impl From<SandboxError> for Error
Source§fn from(err: SandboxError) -> Self
fn from(err: SandboxError) -> Self
Source§impl From<SecurityError> for Error
impl From<SecurityError> for Error
Source§fn from(err: SecurityError) -> Self
fn from(err: SecurityError) -> Self
Source§impl From<SessionError> for Error
impl From<SessionError> for Error
Source§fn from(err: SessionError) -> Self
fn from(err: SessionError) -> Self
Source§impl From<TokenValidationError> for Error
impl From<TokenValidationError> for Error
Source§fn from(source: TokenValidationError) -> Self
fn from(source: TokenValidationError) -> Self
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl !UnwindSafe for Error
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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>
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>
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 moreSource§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.