1use thiserror::Error;
6
7#[derive(Error, Debug)]
9pub enum HyperInferError {
10 #[error("Configuration error: {0}")]
11 Config(#[from] std::io::Error),
12
13 #[error("Rate limiting error: {0}")]
14 RateLimit(String),
15
16 #[error("HTTP request failed: {0}")]
17 Http(#[from] reqwest::Error),
18
19 #[error("API error ({status}): {message}")]
20 ApiError { status: u16, message: String },
21
22 #[error("SSE parse error: {message}")]
23 StreamParse { message: String, raw: String },
24
25 #[error("Database error")]
26 Database(#[from] sqlx::Error),
27
28 #[error("Redis error")]
29 Redis(#[from] redis::RedisError),
30
31 #[error("Streaming not supported by provider: {0}")]
32 UnsupportedStreaming(String),
33}
34
35#[derive(Debug, Error)]
36pub enum DbError {
37 #[error("Database error: {0}")]
38 Sqlx(#[from] sqlx::Error),
39 #[error("Invalid UUID")]
40 InvalidUuid,
41 #[error("Not found")]
42 NotFound,
43 #[error("Unique constraint violation: {0}")]
44 UniqueViolation(String),
45 #[error("Validation error: {0}")]
46 ValidationError(String),
47}
48
49#[derive(Debug, Error)]
50pub enum ConfigError {
51 #[error("Redis error: {0}")]
52 Redis(#[from] redis::RedisError),
53 #[error("Serialization error: {0}")]
54 Serialization(#[from] serde_json::Error),
55 #[error("Configuration error: {0}")]
56 Other(String),
57}