1use thiserror::Error;
4
5#[derive(Debug, Error, Clone)]
7pub enum DioxusAiError {
8 #[error("Request failed: {0}")]
10 RequestFailed(String),
11
12 #[error("Invalid provider: {0}")]
14 InvalidProvider(String),
15
16 #[error("API error: {0}")]
18 ApiError(String),
19
20 #[error("Parse error: {0}")]
22 ParseError(String),
23
24 #[error("Stream error: {0}")]
26 StreamError(String),
27
28 #[error("Missing configuration: {0}")]
30 MissingConfig(String),
31}
32
33impl From<serde_json::Error> for DioxusAiError {
34 fn from(e: serde_json::Error) -> Self {
35 DioxusAiError::ParseError(e.to_string())
36 }
37}
38
39impl From<cortexai_llm_client::LlmClientError> for DioxusAiError {
40 fn from(e: cortexai_llm_client::LlmClientError) -> Self {
41 DioxusAiError::ApiError(e.to_string())
42 }
43}
44
45pub type Result<T> = std::result::Result<T, DioxusAiError>;