File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -78,18 +78,22 @@ pub(crate) fn remove_dir_all(path: &Path) -> std::io::Result<()> {
78
78
79
79
#[ derive( Debug ) ]
80
80
struct RemoveError {
81
- kind : std:: io:: ErrorKind ,
81
+ underlying : std:: io:: Error ,
82
82
path : PathBuf ,
83
83
}
84
84
85
- impl std:: error:: Error for RemoveError { }
85
+ impl std:: error:: Error for RemoveError {
86
+ fn source ( & self ) -> Option < & ( dyn std:: error:: Error + ' static ) > {
87
+ Some ( & self . underlying )
88
+ }
89
+ }
86
90
87
91
impl std:: fmt:: Display for RemoveError {
88
92
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
89
93
f. write_fmt ( format_args ! (
90
94
"failed to remove '{}' : {:?}" ,
91
95
self . path. display( ) ,
92
- self . kind
96
+ self . underlying
93
97
) )
94
98
}
95
99
}
@@ -98,7 +102,7 @@ fn improve_remove_error(error: std::io::Error, path: &Path) -> std::io::Error {
98
102
std:: io:: Error :: new (
99
103
error. kind ( ) ,
100
104
RemoveError {
101
- kind : error. kind ( ) ,
105
+ underlying : error,
102
106
path : path. to_path_buf ( ) ,
103
107
} ,
104
108
)
@@ -112,7 +116,7 @@ mod tests {
112
116
fn custom_remove_error ( ) {
113
117
let path = "test/path" . as_ref ( ) ;
114
118
115
- let expected = "failed to remove 'test/path' : PermissionDenied" ;
119
+ let expected = "failed to remove 'test/path' : Kind( PermissionDenied) " ;
116
120
let tested = format ! (
117
121
"{}" ,
118
122
improve_remove_error(
You can’t perform that action at this time.
0 commit comments