#[non_exhaustive]pub enum AskError {
Show 14 variants
State(InvalidJson),
MissingApiKey,
InvalidApiKey,
InvalidBaseUrl {
url: String,
},
Offline,
TokenLimit {
long_context: bool,
},
ByteLimit {
size: usize,
},
MissingImage {
reference: String,
},
BboxModel {
model: String,
},
Timeout,
Transport(Box<dyn Error + Send + Sync>),
Http {
status: u16,
message: String,
request_id: Option<String>,
},
InvalidResponse {
message: String,
request_id: Option<String>,
},
Cache(CacheError),
}Expand description
An error of ask.
Each message tells the fix, if a fix exists. The message does not hold the cause of the
error. source gives it.
§Examples
use system2::prelude::*;
use system2::AskError;
match noul!("Is the ticket urgent?").ask("The site is down.").await {
Ok(answer) => println!("{:.2}", answer.probability()),
Err(AskError::Offline) => println!("record the response with a run online"),
Err(AskError::Http { status: 429, .. }) => println!("the retries stopped"),
Err(error) => eprintln!("{error}"),
}Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
State(InvalidJson)
The state does not serialize, is not text, an object, or an array, or is empty.
MissingApiKey
The client must send a request, and it has no API key.
InvalidApiKey
The API key is not a valid HTTP header value.
InvalidBaseUrl
The base URL is not an absolute HTTP or HTTPS URL.
Offline
The client is offline, and the cache has no response for the request.
TokenLimit
The request has more tokens than the API permits. It gets no retry.
ByteLimit
The images of the request have more than 32 MiB.
MissingImage
The request refers to an image, and no Image holds it now.
BboxModel
The request has a Bbox, and its model is earlier than jev-1.14.0.
Timeout
An attempt took longer than the timeout, and the retries stopped.
Transport(Box<dyn Error + Send + Sync>)
The connection failed, and the retries stopped. The value is the cause.
Http
The API refused the request with an error status, and the retries stopped.
Fields
InvalidResponse
The response does not have the shape of the API, or does not answer the questions.
Fields
Cache(CacheError)
The client cannot open the cache file, or add to it.
Trait Implementations§
Source§impl Error for AskError
impl Error for AskError
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()