artificial_openai/
error.rs1use artificial_core::error::ArtificialError;
2use reqwest::StatusCode;
3
4#[derive(Debug, thiserror::Error)]
6pub enum OpenAiError {
7 #[error("request failed: {0}")]
8 Http(#[from] reqwest::Error),
9
10 #[error("couldn’t serialise body: {0}")]
11 Serde(#[from] serde_json::Error),
12
13 #[error("OpenAI returned non-success status {status}: {body}")]
14 Api { status: StatusCode, body: String },
15
16 #[error("OpenAI format error: {0}")]
17 Format(String),
18}
19
20impl From<OpenAiError> for ArtificialError {
21 fn from(value: OpenAiError) -> Self {
22 ArtificialError::Backend(Box::new(value))
23 }
24}