@@ -202,7 +202,30 @@ impl Error {
202202/// As a short-term fix, the `Debug` implementation currently always returns a static string.
203203impl Debug for Error {
204204 fn fmt ( & self , f : & mut Formatter < ' _ > ) -> fmt:: Result {
205- f. debug_struct ( "Error" ) . finish ( )
205+ #[ cfg( not( feature = "debug-error" ) ) ]
206+ {
207+ f. debug_struct ( "Error" ) . finish ( )
208+ }
209+ #[ cfg( feature = "debug-error" ) ]
210+ {
211+ match self {
212+ & Self :: IO => f. write_str ( "IO" ) ,
213+ & Self :: CORRUPTION => f. write_str ( "CORRUPTION" ) ,
214+ & Self :: NO_SUCH_ENTRY => f. write_str ( "NO_SUCH_ENTRY" ) ,
215+ & Self :: ENTRY_ALREADY_EXISTED => f. write_str ( "ENTRY_ALREADY_EXISTED" ) ,
216+ & Self :: PATH_NOT_DIR => f. write_str ( "PATH_NOT_DIR" ) ,
217+ & Self :: PATH_IS_DIR => f. write_str ( "PATH_IS_DIR" ) ,
218+ & Self :: DIR_NOT_EMPTY => f. write_str ( "DIR_NOT_EMPTY" ) ,
219+ & Self :: BAD_FILE_DESCRIPTOR => f. write_str ( "BAD_FILE_DESCRIPTOR" ) ,
220+ & Self :: FILE_TOO_BIG => f. write_str ( "FILE_TOO_BIG" ) ,
221+ & Self :: INVALID => f. write_str ( "INVALID" ) ,
222+ & Self :: NO_SPACE => f. write_str ( "NO_SPACE" ) ,
223+ & Self :: NO_MEMORY => f. write_str ( "NO_MEMORY" ) ,
224+ & Self :: NO_ATTRIBUTE => f. write_str ( "NO_ATTRIBUTE" ) ,
225+ & Self :: FILENAME_TOO_LONG => f. write_str ( "FILENAME_TOO_LONG" ) ,
226+ other => f. debug_tuple ( "Error" ) . field ( & other. code ) . finish ( ) ,
227+ }
228+ }
206229 }
207230}
208231
0 commit comments