use ic_agent::AgentError;
use ic_response_verification::ResponseVerificationError;
use std::sync::Arc;
pub type HttpGatewayResult<T = ()> = Result<T, HttpGatewayError>;
#[derive(thiserror::Error, Debug, Clone)]
pub enum HttpGatewayError {
#[error(transparent)]
ResponseVerificationError(#[from] ResponseVerificationError),
#[error(transparent)]
AgentError(#[from] Arc<AgentError>),
#[error(transparent)]
HttpError(#[from] Arc<http::Error>),
#[error(r#"Failed to parse the "{header_name}" header value: "{header_value:?}""#)]
HeaderValueParsingError {
header_name: String,
header_value: String,
},
}
impl From<AgentError> for HttpGatewayError {
fn from(err: AgentError) -> Self {
HttpGatewayError::AgentError(Arc::new(err))
}
}
impl From<http::Error> for HttpGatewayError {
fn from(err: http::Error) -> Self {
HttpGatewayError::HttpError(Arc::new(err))
}
}