11//! The error module contains types for common errors that may be thrown
22//! by other modules in this crate.
33
4+ use ic_agent:: AgentError ;
5+ use ic_response_verification:: ResponseVerificationError ;
46use std:: sync:: Arc ;
57
68/// HTTP gateway result type.
@@ -10,15 +12,15 @@ pub type HttpGatewayResult<T = ()> = Result<T, HttpGatewayError>;
1012#[ derive( thiserror:: Error , Debug , Clone ) ]
1113pub enum HttpGatewayError {
1214 #[ error( transparent) ]
13- ResponseVerificationError ( #[ from] ic_response_verification :: ResponseVerificationError ) ,
15+ ResponseVerificationError ( #[ from] ResponseVerificationError ) ,
1416
1517 /// Inner error from agent.
1618 #[ error( transparent) ]
17- AgentError ( #[ from] Arc < ic_agent :: AgentError > ) ,
19+ AgentError ( #[ from] Arc < AgentError > ) ,
1820
1921 /// HTTP error.
20- #[ error( r#"HTTP error: "{0}""# ) ]
21- HttpError ( String ) ,
22+ #[ error( transparent ) ]
23+ HttpError ( # [ from ] Arc < http :: Error > ) ,
2224
2325 #[ error( r#"Failed to parse the "{header_name}" header value: "{header_value:?}""# ) ]
2426 HeaderValueParsingError {
@@ -27,20 +29,14 @@ pub enum HttpGatewayError {
2729 } ,
2830}
2931
30- impl From < ic_agent :: AgentError > for HttpGatewayError {
31- fn from ( err : ic_agent :: AgentError ) -> Self {
32+ impl From < AgentError > for HttpGatewayError {
33+ fn from ( err : AgentError ) -> Self {
3234 HttpGatewayError :: AgentError ( Arc :: new ( err) )
3335 }
3436}
3537
3638impl From < http:: Error > for HttpGatewayError {
3739 fn from ( err : http:: Error ) -> Self {
38- HttpGatewayError :: HttpError ( err. to_string ( ) )
39- }
40- }
41-
42- impl From < http:: status:: InvalidStatusCode > for HttpGatewayError {
43- fn from ( err : http:: status:: InvalidStatusCode ) -> Self {
44- HttpGatewayError :: HttpError ( err. to_string ( ) )
40+ HttpGatewayError :: HttpError ( Arc :: new ( err) )
4541 }
4642}
0 commit comments