a2a_rs/adapter/error/
server.rs1#[cfg(feature = "http-server")]
4use std::io;
5
6#[cfg(feature = "http-server")]
7use thiserror::Error;
8
9#[derive(Error, Debug)]
11#[cfg(feature = "http-server")]
12pub enum HttpServerError {
13 #[error("HTTP server error: {0}")]
15 Server(String),
16
17 #[error("IO error: {0}")]
19 Io(#[from] io::Error),
20
21 #[error("JSON serialization error: {0}")]
23 Json(#[from] serde_json::Error),
24
25 #[error("Invalid request format: {0}")]
27 InvalidRequest(String),
28}
29
30#[cfg(feature = "http-server")]
32impl From<HttpServerError> for crate::domain::A2AError {
33 fn from(error: HttpServerError) -> Self {
34 match error {
35 HttpServerError::Server(msg) => {
36 crate::domain::A2AError::Internal(format!("HTTP server error: {}", msg))
37 }
38 HttpServerError::Io(e) => crate::domain::A2AError::Io(e),
39 HttpServerError::Json(e) => crate::domain::A2AError::JsonParse(e),
40 HttpServerError::InvalidRequest(msg) => crate::domain::A2AError::InvalidRequest(msg),
41 }
42 }
43}