@@ -7,6 +7,7 @@ use std::net::TcpStream;
77use std:: result;
88use std:: str:: Utf8Error ;
99
10+ use base64:: DecodeError ;
1011use bufstream:: IntoInnerError as BufError ;
1112use imap_proto:: { types:: ResponseCode , Response } ;
1213#[ cfg( feature = "native-tls" ) ]
@@ -239,7 +240,7 @@ pub enum ParseError {
239240 /// Indicates an error parsing the status response. Such as OK, NO, and BAD.
240241 Invalid ( Vec < u8 > ) ,
241242 /// The client could not find or decode the server's authentication challenge.
242- Authentication ( String ) ,
243+ Authentication ( String , Option < DecodeError > ) ,
243244 /// The client received data that was not UTF-8 encoded.
244245 DataNotUtf8 ( Vec < u8 > , Utf8Error ) ,
245246}
@@ -248,7 +249,7 @@ impl fmt::Display for ParseError {
248249 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
249250 match * self {
250251 ParseError :: Invalid ( _) => f. write_str ( "Unable to parse status response" ) ,
251- ParseError :: Authentication ( _) => {
252+ ParseError :: Authentication ( _, _ ) => {
252253 f. write_str ( "Unable to parse authentication response" )
253254 }
254255 ParseError :: DataNotUtf8 ( _, _) => f. write_str ( "Unable to parse data as UTF-8 text" ) ,
@@ -260,10 +261,17 @@ impl StdError for ParseError {
260261 fn description ( & self ) -> & str {
261262 match * self {
262263 ParseError :: Invalid ( _) => "Unable to parse status response" ,
263- ParseError :: Authentication ( _) => "Unable to parse authentication response" ,
264+ ParseError :: Authentication ( _, _ ) => "Unable to parse authentication response" ,
264265 ParseError :: DataNotUtf8 ( _, _) => "Unable to parse data as UTF-8 text" ,
265266 }
266267 }
268+
269+ fn cause ( & self ) -> Option < & dyn StdError > {
270+ match * self {
271+ ParseError :: Authentication ( _, Some ( ref e) ) => Some ( e) ,
272+ _ => None ,
273+ }
274+ }
267275}
268276
269277/// An [invalid character](https://tools.ietf.org/html/rfc3501#section-4.3) was found in a command
0 commit comments