gitdataai/libs/agent/error.rs
2026-04-14 19:02:01 +08:00

32 lines
762 B
Rust

use thiserror::Error;
#[derive(Error, Debug)]
pub enum AgentError {
#[error("openai error: {0}")]
OpenAi(String),
#[error("qdrant error: {0}")]
Qdrant(String),
#[error("internal error: {0}")]
Internal(String),
}
pub type Result<T> = std::result::Result<T, AgentError>;
impl From<async_openai::error::OpenAIError> for AgentError {
fn from(e: async_openai::error::OpenAIError) -> Self {
AgentError::OpenAi(e.to_string())
}
}
impl From<qdrant_client::QdrantError> for AgentError {
fn from(e: qdrant_client::QdrantError) -> Self {
AgentError::Qdrant(e.to_string())
}
}
impl From<sea_orm::DbErr> for AgentError {
fn from(e: sea_orm::DbErr) -> Self {
AgentError::Internal(e.to_string())
}
}