pub struct ApiError {
pub status: u16,
pub kind: ApiErrorKind,
pub message: String,
pub code: Option<String>,
pub type: Option<String>,
}Expand description
表示由 OpenAI API 返回的错误。
Fields§
§status: u16§kind: ApiErrorKind§message: String§code: Option<String>§type: Option<String>Implementations§
Source§impl ApiError
impl ApiError
Sourcepub fn is_authentication(&self) -> bool
pub fn is_authentication(&self) -> bool
如果错误是身份验证错误(HTTP 401),则返回 true。
Sourcepub fn is_rate_limit(&self) -> bool
pub fn is_rate_limit(&self) -> bool
如果错误是速率限制错误(HTTP 429),则返回 true。
Sourcepub fn is_server_error(&self) -> bool
pub fn is_server_error(&self) -> bool
如果错误是服务器端错误(HTTP 5xx),则返回 true。
Sourcepub fn is_bad_request(&self) -> bool
pub fn is_bad_request(&self) -> bool
如果错误是错误请求错误(HTTP 400),则返回 true。
Sourcepub fn is_conflict(&self) -> bool
pub fn is_conflict(&self) -> bool
如果请求冲突(HTTP 409),则返回 true。
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
如果导致错误的请求在重试时可能成功,则返回 true。
Trait Implementations§
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()
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
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.