pub enum OpenAIError {
Http(Error),
Body(BodyError),
Stream(ParseError),
Json(Error),
Decode(DecodeError),
Api(String),
RateLimit {
message: String,
retry_after: Option<Duration>,
},
ServerError {
status: u16,
message: String,
},
Timeout,
}Expand description
Errors that can arise when calling the OpenAI API.
Variants§
Http(Error)
HTTP layer errors.
Body(BodyError)
Response body parsing failures.
Stream(ParseError)
SSE parsing failures.
Json(Error)
JSON serialization/deserialization errors.
Decode(DecodeError)
Base64 decoding failures (e.g., image payloads).
Api(String)
API contract violations or unsupported operations.
RateLimit
Rate limit exceeded (HTTP 429).
Fields
ServerError
Server error (HTTP 5xx).
Timeout
Request timed out.
Trait Implementations§
Source§impl Debug for OpenAIError
impl Debug for OpenAIError
Source§impl Display for OpenAIError
impl Display for OpenAIError
Source§impl Error for OpenAIError
impl Error for OpenAIError
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<DecodeError> for OpenAIError
impl From<DecodeError> for OpenAIError
Source§fn from(value: DecodeError) -> Self
fn from(value: DecodeError) -> Self
Converts to this type from the input type.
Source§impl From<Error> for OpenAIError
impl From<Error> for OpenAIError
Source§impl From<Error> for OpenAIError
impl From<Error> for OpenAIError
Source§impl From<Error> for OpenAIError
impl From<Error> for OpenAIError
Source§impl From<ParseError> for OpenAIError
impl From<ParseError> for OpenAIError
Source§fn from(value: SseParseError) -> Self
fn from(value: SseParseError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl !RefUnwindSafe for OpenAIError
impl !UnwindSafe for OpenAIError
impl Freeze for OpenAIError
impl Send for OpenAIError
impl Sync for OpenAIError
impl Unpin for OpenAIError
impl UnsafeUnpin for OpenAIError
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more