@@ -7,6 +7,7 @@ use std::net::TcpStream;
7
7
use std:: result;
8
8
use std:: str:: Utf8Error ;
9
9
10
+ use base64:: DecodeError ;
10
11
use bufstream:: IntoInnerError as BufError ;
11
12
use imap_proto:: { types:: ResponseCode , Response } ;
12
13
#[ cfg( feature = "native-tls" ) ]
@@ -239,7 +240,7 @@ pub enum ParseError {
239
240
/// Indicates an error parsing the status response. Such as OK, NO, and BAD.
240
241
Invalid ( Vec < u8 > ) ,
241
242
/// The client could not find or decode the server's authentication challenge.
242
- Authentication ( String ) ,
243
+ Authentication ( String , Option < DecodeError > ) ,
243
244
/// The client received data that was not UTF-8 encoded.
244
245
DataNotUtf8 ( Vec < u8 > , Utf8Error ) ,
245
246
}
@@ -248,7 +249,7 @@ impl fmt::Display for ParseError {
248
249
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
249
250
match * self {
250
251
ParseError :: Invalid ( _) => f. write_str ( "Unable to parse status response" ) ,
251
- ParseError :: Authentication ( _) => {
252
+ ParseError :: Authentication ( _, _ ) => {
252
253
f. write_str ( "Unable to parse authentication response" )
253
254
}
254
255
ParseError :: DataNotUtf8 ( _, _) => f. write_str ( "Unable to parse data as UTF-8 text" ) ,
@@ -260,10 +261,17 @@ impl StdError for ParseError {
260
261
fn description ( & self ) -> & str {
261
262
match * self {
262
263
ParseError :: Invalid ( _) => "Unable to parse status response" ,
263
- ParseError :: Authentication ( _) => "Unable to parse authentication response" ,
264
+ ParseError :: Authentication ( _, _ ) => "Unable to parse authentication response" ,
264
265
ParseError :: DataNotUtf8 ( _, _) => "Unable to parse data as UTF-8 text" ,
265
266
}
266
267
}
268
+
269
+ fn cause ( & self ) -> Option < & dyn StdError > {
270
+ match * self {
271
+ ParseError :: Authentication ( _, Some ( ref e) ) => Some ( e) ,
272
+ _ => None ,
273
+ }
274
+ }
267
275
}
268
276
269
277
/// An [invalid character](https://tools.ietf.org/html/rfc3501#section-4.3) was found in a command
0 commit comments