#[non_exhaustive]pub enum Error {
MissingApiKey,
InvalidRequest(String),
Connection(TransportError),
Timeout {
after: Duration,
},
Api(Box<ApiError>),
Decode {
source: Error,
body: Bytes,
meta: Box<ResponseMeta>,
},
UnexpectedShape {
endpoint: &'static str,
meta: Box<ResponseMeta>,
},
}Expand description
SDK error taxonomy, aligned with the official TypeScript classes.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
MissingApiKey
No API key in config or TYPESAFE_API_KEY.
InvalidRequest(String)
Client-side validation failed before a network call.
Connection(TransportError)
DNS, TLS, or connection failure (APIConnectionError).
Timeout
The attempt exceeded the configured timeout (APITimeoutError).
Api(Box<ApiError>)
Non-2xx HTTP response after retries are exhausted.
Decode
Response body was not valid JSON for the expected type.
Fields
meta: Box<ResponseMeta>HTTP metadata from the failing attempt.
UnexpectedShape
JSON parsed but did not have the documented shape.
Fields
meta: Box<ResponseMeta>HTTP metadata from the failing attempt.
Implementations§
Source§impl Error
impl Error
Sourcepub fn request_id(&self) -> Option<&str>
pub fn request_id(&self) -> Option<&str>
x-typesafe-request-id when this error came from an HTTP response.
Sourcepub fn status(&self) -> Option<StatusCode>
pub fn status(&self) -> Option<StatusCode>
HTTP status when this error came from an HTTP response.
Sourcepub fn kind(&self) -> Option<ApiErrorKind>
pub fn kind(&self) -> Option<ApiErrorKind>
HTTP status class when this is an API error.
Sourcepub fn is_rate_limited(&self) -> bool
pub fn is_rate_limited(&self) -> bool
True when the API returned HTTP 429.
Sourcepub fn is_timeout(&self) -> bool
pub fn is_timeout(&self) -> bool
True when the attempt timed out.
Sourcepub fn is_connection(&self) -> bool
pub fn is_connection(&self) -> bool
True when a transport/connection failure occurred.
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
use the Display impl or to_string()