use serde::Deserialize;
use thiserror::Error;
#[derive(Debug, Deserialize, PartialEq, Clone)]
pub struct AnthropicErrorBody {
pub r#type: String,
pub error: AnthropicErrorDetails,
}
#[derive(Debug, Deserialize, PartialEq, Clone)]
pub struct AnthropicErrorDetails {
pub r#type: String,
pub message: String,
}
#[derive(Error, Debug, PartialEq, Clone)]
pub enum AnthropicError {
#[error("Invalid Request Error: {0:?}")]
CODE400(AnthropicErrorBody),
#[error("Authentication Error: {0:?}")]
CODE401(AnthropicErrorBody),
#[error("Permission Error: {0:?}")]
CODE403(AnthropicErrorBody),
#[error("Not Found Error: {0:?}")]
CODE404(AnthropicErrorBody),
#[error("Request Too Large Error: {0:?}")]
CODE413(AnthropicErrorBody),
#[error("Rate Limit Error: {0:?}")]
CODE429(AnthropicErrorBody),
#[error("API Error: {0:?}")]
CODE500(AnthropicErrorBody),
#[error("Overloaded Error: {0:?}")]
CODE503(AnthropicErrorBody),
#[error("Undefined Error. This should not happen, if this is a missed error please report it: https://github.com/JackMatthewRimmer/rust-rag-toolchain: status code = {0}, error = {1}")]
Undefined(u16, String),
#[error("Error sending request: {0}")]
ErrorSendingRequest(String),
#[error("Error getting response body: {0}")]
ErrorGettingResponseBody(String),
#[error("Error deserializining response body: status code = {0}, error = {1}")]
ErrorDeserializingResponseBody(u16, String),
}