rag_toolchain/clients/anthropic/model/
errors.rs1use serde::Deserialize;
2use thiserror::Error;
3
4#[derive(Debug, Deserialize, PartialEq, Clone)]
5pub struct AnthropicErrorBody {
6 pub r#type: String,
7 pub error: AnthropicErrorDetails,
8}
9
10#[derive(Debug, Deserialize, PartialEq, Clone)]
11pub struct AnthropicErrorDetails {
12 pub r#type: String,
13 pub message: String,
14}
15
16#[derive(Error, Debug, PartialEq, Clone)]
21pub enum AnthropicError {
22 #[error("Invalid Request Error: {0:?}")]
25 CODE400(AnthropicErrorBody),
26 #[error("Authentication Error: {0:?}")]
28 CODE401(AnthropicErrorBody),
29 #[error("Permission Error: {0:?}")]
31 CODE403(AnthropicErrorBody),
32 #[error("Not Found Error: {0:?}")]
34 CODE404(AnthropicErrorBody),
35 #[error("Request Too Large Error: {0:?}")]
37 CODE413(AnthropicErrorBody),
38 #[error("Rate Limit Error: {0:?}")]
40 CODE429(AnthropicErrorBody),
41 #[error("API Error: {0:?}")]
43 CODE500(AnthropicErrorBody),
44 #[error("Overloaded Error: {0:?}")]
46 CODE503(AnthropicErrorBody),
47 #[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}")]
49 Undefined(u16, String),
50 #[error("Error sending request: {0}")]
52 ErrorSendingRequest(String),
53 #[error("Error getting response body: {0}")]
55 ErrorGettingResponseBody(String),
56 #[error("Error deserializining response body: status code = {0}, error = {1}")]
58 ErrorDeserializingResponseBody(u16, String),
59}