pub struct ModelApiError {
pub status_code: u16,
pub body: String,
pub headers: HashMap<String, String>,
pub message: Option<String>,
pub error_code: Option<String>,
pub retryable: bool,
pub retry_after: Option<u64>,
}Expand description
API error from the model provider.
Fields§
§status_code: u16HTTP status code.
body: StringResponse body.
headers: HashMap<String, String>Response headers.
message: Option<String>Error message from the API.
error_code: Option<String>Error code from the API.
retryable: boolWhether this error is retryable.
retry_after: Option<u64>Retry-after header value in seconds.
Implementations§
Source§impl ModelApiError
impl ModelApiError
Sourcepub fn with_message(self, message: impl Into<String>) -> Self
pub fn with_message(self, message: impl Into<String>) -> Self
Set the message.
Sourcepub fn with_error_code(self, code: impl Into<String>) -> Self
pub fn with_error_code(self, code: impl Into<String>) -> Self
Set the error code.
Sourcepub fn with_headers(self, headers: HashMap<String, String>) -> Self
pub fn with_headers(self, headers: HashMap<String, String>) -> Self
Set headers.
Sourcepub fn is_rate_limit(&self) -> bool
pub fn is_rate_limit(&self) -> bool
Check if this is a rate limit error.
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
Check if this is a server error.
Trait Implementations§
Source§impl Clone for ModelApiError
impl Clone for ModelApiError
Source§fn clone(&self) -> ModelApiError
fn clone(&self) -> ModelApiError
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 ModelApiError
impl Debug for ModelApiError
Source§impl Display for ModelApiError
impl Display for ModelApiError
Source§impl Error for ModelApiError
impl Error for ModelApiError
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()
Source§impl From<ModelApiError> for SerdesAiError
impl From<ModelApiError> for SerdesAiError
Source§fn from(source: ModelApiError) -> Self
fn from(source: ModelApiError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for ModelApiError
impl RefUnwindSafe for ModelApiError
impl Send for ModelApiError
impl Sync for ModelApiError
impl Unpin for ModelApiError
impl UnwindSafe for ModelApiError
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