mirror of
https://github.com/mii443/openai-api-rs.git
synced 2025-12-05 20:18:24 +00:00
* use reqwest
* support multipart form * fix audio apits
This commit is contained in:
@@ -1,15 +1,26 @@
|
||||
use reqwest::{self};
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct APIError {
|
||||
pub message: String,
|
||||
pub enum APIError {
|
||||
ReqwestError(reqwest::Error),
|
||||
CustomError { message: String },
|
||||
}
|
||||
|
||||
impl fmt::Display for APIError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "APIError: {}", self.message)
|
||||
match self {
|
||||
APIError::ReqwestError(err) => write!(f, "ReqwestError: {}", err),
|
||||
APIError::CustomError { message } => write!(f, "APIError: {}", message),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for APIError {}
|
||||
|
||||
impl From<reqwest::Error> for APIError {
|
||||
fn from(err: reqwest::Error) -> APIError {
|
||||
APIError::ReqwestError(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user