feat!: add missing api key error

BREAKING CHANGE: `APIError` is renamed to `ApiError`.
This commit is contained in:
Ivan Gabriele
2024-03-04 04:21:03 +01:00
parent b0a3f10c9f
commit 1deab88251
10 changed files with 64 additions and 47 deletions

View File

@@ -2,14 +2,18 @@ use std::error::Error;
use std::fmt;
#[derive(Debug)]
pub struct APIError {
pub struct ApiError {
pub message: String,
}
impl fmt::Display for APIError {
impl fmt::Display for ApiError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "APIError: {}", self.message)
write!(f, "ApiError: {}", self.message)
}
}
impl Error for ApiError {}
impl Error for APIError {}
#[derive(Debug, thiserror::Error)]
pub enum ClientError {
#[error("You must either set the `MISTRAL_API_KEY` environment variable or specify it in `Client::new(api_key, ...).")]
ApiKeyError,
}