openai_agents_rust/
error.rs1use thiserror::Error;
2
3#[derive(Error, Debug)]
5pub enum AgentError {
6 #[error("Configuration error: {0}")]
7 ConfigError(#[from] config::ConfigError),
8
9 #[error("IO error: {0}")]
10 IoError(#[from] std::io::Error),
11
12 #[error("HTTP request error: {0}")]
13 HttpError(#[from] reqwest::Error),
14
15 #[error("Serialization/Deserialization error: {0}")]
16 SerdeError(#[from] serde_json::Error),
17
18 #[error("YAML error: {0}")]
19 YamlError(#[from] rust_yaml::Error),
20
21 #[error("Plugin loading error: {0}")]
22 PluginError(String),
23
24 #[error("Other error: {0}")]
25 Other(String),
26}
27
28impl axum::response::IntoResponse for AgentError {
30 fn into_response(self) -> axum::response::Response {
31 let body = axum::Json(serde_json::json!({ "error": self.to_string() }));
32 (axum::http::StatusCode::INTERNAL_SERVER_ERROR, body).into_response()
33 }
34}