pub struct ApiError {
pub status: u16,
pub kind: ApiErrorKind,
pub message: Option<String>,
pub error_type: Option<String>,
pub code: Option<String>,
pub param: Option<String>,
pub request_id: Option<String>,
pub body: Option<Value>,
}Expand description
A response with a non-2xx status (APIStatusError in the SDKs).
Fields§
§status: u16§kind: ApiErrorKind§message: Option<String>error.message from the body; otherwise the whole body (truncated).
error_type: Option<String>error.type, e.g. rate_limit_error (Anthropic) or invalid_request_error (OpenAI).
code: Option<String>error.code (OpenAI).
param: Option<String>error.param (OpenAI).
request_id: Option<String>request-id (Anthropic) or x-request-id (OpenAI) header — quote it to support.
body: Option<Value>The response body, if it was JSON.
Trait Implementations§
Source§impl Display for ApiError
Same format as APIError.makeMessage in the SDKs: "{status} {message}"
or "{status} status code (no body)".
impl Display for ApiError
Same format as APIError.makeMessage in the SDKs: "{status} {message}"
or "{status} status code (no body)".
Source§impl Error for ApiError
impl Error for ApiError
1.30.0 · 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()
impl StructuralPartialEq for ApiError
Auto Trait Implementations§
impl Freeze for ApiError
impl RefUnwindSafe for ApiError
impl Send for ApiError
impl Sync for ApiError
impl Unpin for ApiError
impl UnsafeUnpin for ApiError
impl UnwindSafe for ApiError
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