llm_observatory_core/
error.rs1pub type Result<T> = std::result::Result<T, Error>;
8
9#[derive(Debug, thiserror::Error)]
11pub enum Error {
12 #[error("Configuration error: {0}")]
14 Config(String),
15
16 #[error("Provider error: {0}")]
18 Provider(String),
19
20 #[error("Storage error: {0}")]
22 Storage(String),
23
24 #[error("Serialization error: {0}")]
26 Serialization(#[from] serde_json::Error),
27
28 #[error("OpenTelemetry error: {0}")]
30 OpenTelemetry(String),
31
32 #[error("Authentication error: {0}")]
34 Auth(String),
35
36 #[error("Resource not found: {0}")]
38 NotFound(String),
39
40 #[error("Invalid input: {0}")]
42 InvalidInput(String),
43
44 #[error("Internal error: {0}")]
46 Internal(String),
47
48 #[error("IO error: {0}")]
50 Io(#[from] std::io::Error),
51}
52
53impl Error {
54 pub fn config(msg: impl Into<String>) -> Self {
56 Self::Config(msg.into())
57 }
58
59 pub fn provider(msg: impl Into<String>) -> Self {
61 Self::Provider(msg.into())
62 }
63
64 pub fn storage(msg: impl Into<String>) -> Self {
66 Self::Storage(msg.into())
67 }
68
69 pub fn auth(msg: impl Into<String>) -> Self {
71 Self::Auth(msg.into())
72 }
73
74 pub fn not_found(msg: impl Into<String>) -> Self {
76 Self::NotFound(msg.into())
77 }
78
79 pub fn invalid_input(msg: impl Into<String>) -> Self {
81 Self::InvalidInput(msg.into())
82 }
83
84 pub fn internal(msg: impl Into<String>) -> Self {
86 Self::Internal(msg.into())
87 }
88}