#[non_exhaustive]pub enum Error {
Auth(String),
TokenLimit(String),
InvalidRequest(String),
InvalidConfig(String),
Api(String),
}Expand description
Why a client could not be built, or a request could not be answered.
Transient failures (connection errors, HTTP 429, 5xx) are retried inside
Client::ask and only surface as Error::Api once the retries are
spent. The other variants are returned at once, because retrying cannot help.
The enum is #[non_exhaustive]: a later version may tell more failures apart, so a match
needs a wildcard arm. Error::message and Display give the text of any variant.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Auth(String)
Missing, blank, unsendable or rejected credentials (HTTP 401 or 403).
TokenLimit(String)
The request exceeded the model’s context (max_tokens_exceeded, or HTTP 413). Ask fewer
questions, or about less state, and retry.
InvalidRequest(String)
A request the API would not evaluate: a state that does not serialize to JSON, or a body
the API refused as malformed (HTTP 422), such as a Score with a single
level or a state that is a bare number. The message quotes what the API objected to.
InvalidConfig(String)
A Config no request could be sent with: a base URL that is not an
absolute http or https URL, or a user agent that is not a valid header value.
Reported by Client::new, before anything is sent.
Api(String)
Anything else: an unreadable response, an unexpected status, or retries exhausted.
Implementations§
Trait Implementations§
impl Eq for Error
Source§impl Error for Error
impl Error for Error
1.30.0 · 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()
impl StructuralPartialEq for Error
Auto Trait Implementations§
impl Freeze for Error
impl RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl UnwindSafe for Error
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.