@@ -27,7 +27,7 @@ pub enum Error {
2727
2828 IOError ( Arc < io:: Error > ) ,
2929 ParsingError ( ParserError ) ,
30- ProtocolError ( AMQPError ) ,
30+ ProtocolError ( AMQPError , Option < Notifier > ) ,
3131 SerialisationError ( Arc < GenError > ) ,
3232
3333 MissingHeartbeatError ,
@@ -53,23 +53,30 @@ impl Error {
5353 }
5454 }
5555
56- pub fn is_amqp_soft_error ( & self ) -> bool {
57- if let Error :: ProtocolError ( e) = self {
56+ pub fn is_amqp_soft_error ( & self ) -> ( bool , Option < Notifier > ) {
57+ if let Error :: ProtocolError ( e, notifier ) = self {
5858 if let AMQPErrorKind :: Soft ( _) = e. kind ( ) {
59- return true ;
59+ return ( true , notifier . clone ( ) ) ;
6060 }
6161 }
62- false
62+ ( false , None )
6363 }
6464
6565 pub fn is_amqp_hard_error ( & self ) -> bool {
66- if let Error :: ProtocolError ( e) = self {
66+ if let Error :: ProtocolError ( e, _ ) = self {
6767 if let AMQPErrorKind :: Hard ( _) = e. kind ( ) {
6868 return true ;
6969 }
7070 }
7171 false
7272 }
73+
74+ pub ( crate ) fn with_notifier ( self , notifier : Notifier ) -> Self {
75+ match self {
76+ Self :: ProtocolError ( err, _) => Self :: ProtocolError ( err, Some ( notifier) ) ,
77+ err => err,
78+ }
79+ }
7380}
7481
7582impl fmt:: Display for Error {
@@ -91,7 +98,7 @@ impl fmt::Display for Error {
9198
9299 Error :: IOError ( e) => write ! ( f, "IO error: {}" , e) ,
93100 Error :: ParsingError ( e) => write ! ( f, "failed to parse: {}" , e) ,
94- Error :: ProtocolError ( e) => write ! ( f, "protocol error: {}" , e) ,
101+ Error :: ProtocolError ( e, _ ) => write ! ( f, "protocol error: {}" , e) ,
95102 Error :: SerialisationError ( e) => write ! ( f, "failed to serialise: {}" , e) ,
96103
97104 Error :: MissingHeartbeatError => {
@@ -119,7 +126,7 @@ impl error::Error for Error {
119126 match self {
120127 Error :: IOError ( e) => Some ( & * * e) ,
121128 Error :: ParsingError ( e) => Some ( e) ,
122- Error :: ProtocolError ( e) => Some ( e) ,
129+ Error :: ProtocolError ( e, _ ) => Some ( e) ,
123130 Error :: SerialisationError ( e) => Some ( & * * e) ,
124131 _ => None ,
125132 }
@@ -156,7 +163,9 @@ impl PartialEq for Error {
156163 false
157164 }
158165 ( ParsingError ( left_inner) , ParsingError ( right_inner) ) => left_inner == right_inner,
159- ( ProtocolError ( left_inner) , ProtocolError ( right_inner) ) => left_inner == right_inner,
166+ ( ProtocolError ( left_inner, _) , ProtocolError ( right_inner, _) ) => {
167+ left_inner == right_inner
168+ }
160169 ( SerialisationError ( _) , SerialisationError ( _) ) => {
161170 error ! ( "Unable to compare lapin::Error::SerialisationError" ) ;
162171 false
0 commit comments