#[non_exhaustive]pub enum Error {
Http(Error),
ApiError {
code: i64,
msg: String,
},
Json(Error),
Hex(FromHexError),
NotSse {
status: StatusCode,
},
UnexpectedStatus {
status: StatusCode,
body: String,
},
EmptyAudio,
MissingField(&'static str),
Other(String),
}Expand description
Errors returned by the MiniMax API client.
This enum is #[non_exhaustive]: new variants may be added in future
releases, so downstream match expressions need a _ arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Http(Error)
The HTTP request could not be completed (connection failure, timeout, TLS error, and so on).
ApiError
MiniMax accepted the request but reported an error in base_resp.
Common codes are 1002 (rate limited), 1004 (authentication failed),
1008 (insufficient balance) and 2013 (invalid parameters).
Fields
Json(Error)
The response body could not be parsed as the expected JSON shape.
Hex(FromHexError)
A hex-encoded audio payload could not be decoded.
NotSse
A streaming endpoint replied without a text/event-stream body.
Fields
status: StatusCodeThe HTTP status of the offending response.
UnexpectedStatus
The server returned a non-success HTTP status and no usable
base_resp error to report.
Fields
status: StatusCodeThe HTTP status returned by the server.
EmptyAudio
The request succeeded but carried no audio payload.
MissingField(&'static str)
A required field was absent from an otherwise successful response.
Other(String)
Any other error that does not fit the variants above.
Implementations§
Source§impl Error
impl Error
Sourcepub fn api_code(&self) -> Option<i64>
pub fn api_code(&self) -> Option<i64>
The MiniMax base_resp.status_code, if this is an Error::ApiError.
Sourcepub fn status(&self) -> Option<StatusCode>
pub fn status(&self) -> Option<StatusCode>
The HTTP status carried by this error, when there is one.
Sourcepub fn is_auth_error(&self) -> bool
pub fn is_auth_error(&self) -> bool
Whether the request failed because the API key was rejected.
Sourcepub fn is_rate_limited(&self) -> bool
pub fn is_rate_limited(&self) -> bool
Whether the request was rejected for exceeding a rate limit.
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Whether retrying the same request has a reasonable chance of success.
Covers transport-level timeouts and connection failures, rate limits, and server-side errors. It is still up to the caller to apply a backoff.
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()