pub struct AnthropicError {
pub error: AnthropicErrorDetails,
pub request_id: Option<String>,
}Expand description
API error message from Anthropic.
When Claude Code encounters an API error (e.g., 500, 529 overloaded), it outputs
a JSON message with type: "error". This struct captures that error information.
§Example JSON
{
"type": "error",
"error": {
"type": "api_error",
"message": "Internal server error"
},
"request_id": "req_011CXPC6BqUogB959LWEf52X"
}§Example
use claude_codes::ClaudeOutput;
let json = r#"{"type":"error","error":{"type":"api_error","message":"Internal server error"},"request_id":"req_123"}"#;
let output: ClaudeOutput = serde_json::from_str(json).unwrap();
if let ClaudeOutput::Error(err) = output {
println!("Error type: {}", err.error.error_type);
println!("Message: {}", err.error.message);
}Fields§
§error: AnthropicErrorDetailsThe nested error details
request_id: Option<String>The request ID for debugging/support
Implementations§
Source§impl AnthropicError
impl AnthropicError
Sourcepub fn is_overloaded(&self) -> bool
pub fn is_overloaded(&self) -> bool
Check if this is an overloaded error (HTTP 529)
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Check if this is a server error (HTTP 500)
Sourcepub fn is_invalid_request(&self) -> bool
pub fn is_invalid_request(&self) -> bool
Check if this is an invalid request error (HTTP 400)
Sourcepub fn is_authentication_error(&self) -> bool
pub fn is_authentication_error(&self) -> bool
Check if this is an authentication error (HTTP 401)
Sourcepub fn is_rate_limited(&self) -> bool
pub fn is_rate_limited(&self) -> bool
Check if this is a rate limit error (HTTP 429)
Trait Implementations§
Source§impl Clone for AnthropicError
impl Clone for AnthropicError
Source§fn clone(&self) -> AnthropicError
fn clone(&self) -> AnthropicError
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for AnthropicError
impl Debug for AnthropicError
Source§impl<'de> Deserialize<'de> for AnthropicError
impl<'de> Deserialize<'de> for AnthropicError
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for AnthropicError
impl PartialEq for AnthropicError
Source§impl Serialize for AnthropicError
impl Serialize for AnthropicError
impl StructuralPartialEq for AnthropicError
Auto Trait Implementations§
impl Freeze for AnthropicError
impl RefUnwindSafe for AnthropicError
impl Send for AnthropicError
impl Sync for AnthropicError
impl Unpin for AnthropicError
impl UnsafeUnpin for AnthropicError
impl UnwindSafe for AnthropicError
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