1use ic_agent::AgentError;
5use ic_response_verification::ResponseVerificationError;
6use std::sync::Arc;
7
8pub type HttpGatewayResult<T = ()> = Result<T, HttpGatewayError>;
10
11#[derive(thiserror::Error, Debug, Clone)]
13pub enum HttpGatewayError {
14 #[error(transparent)]
15 ResponseVerificationError(#[from] ResponseVerificationError),
16
17 #[error(transparent)]
19 AgentError(#[from] Arc<AgentError>),
20
21 #[error(transparent)]
23 HttpError(#[from] Arc<http::Error>),
24
25 #[error(r#"Failed to parse the "{header_name}" header value: "{header_value:?}""#)]
26 HeaderValueParsingError {
27 header_name: String,
28 header_value: String,
29 },
30}
31
32impl From<AgentError> for HttpGatewayError {
33 fn from(err: AgentError) -> Self {
34 HttpGatewayError::AgentError(Arc::new(err))
35 }
36}
37
38impl From<http::Error> for HttpGatewayError {
39 fn from(err: http::Error) -> Self {
40 HttpGatewayError::HttpError(Arc::new(err))
41 }
42}