#[non_exhaustive]pub enum ChatError {
RequestError(Error),
JsonSerializeError(Error, ChatRequest),
ApiDidNotReturnJson {
response: String,
request: String,
error: Error,
},
ApiParseError {
response: Value,
error: Error,
request: String,
},
ApiError(OpenAiError, String),
ChatError(IndividualChatError),
IoError(Error),
NoChoices,
CacheMiss,
}Expand description
Errors that can occur when interacting with the ChatGPT API.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
RequestError(Error)
An error occurred when sending the request to the API.
JsonSerializeError(Error, ChatRequest)
An error occurred when serializing the request to JSON.
ApiDidNotReturnJson
The API did not return a JSON object.
Fields
ApiParseError
The API returned a response could not be parsed into the structure expected of OpenAI responses
Fields
ApiError(OpenAiError, String)
An error occurred when deserializing the response from the API.
ChatError(IndividualChatError)
The API returned a response that was not a valid JSON object.
IoError(Error)
IO error (usually occurs when reading from the cache).
NoChoices
The API did not return any choices.
CacheMiss
The request was not found in the cache and the client is in cached-only mode.
Trait Implementations§
Source§impl Error for ChatError
impl Error for ChatError
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<IndividualChatError> for ChatError
impl From<IndividualChatError> for ChatError
Source§fn from(source: IndividualChatError) -> Self
fn from(source: IndividualChatError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for ChatError
impl !RefUnwindSafe for ChatError
impl Send for ChatError
impl Sync for ChatError
impl Unpin for ChatError
impl UnsafeUnpin for ChatError
impl !UnwindSafe for ChatError
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