File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,18 @@ pub enum Error {
28
28
WalkDir ( walkdir:: Error ) ,
29
29
}
30
30
31
+ impl std:: fmt:: Display for Error {
32
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
33
+ match self {
34
+ Error :: Io ( inner) => write ! ( f, "I/O error: {}" , inner) ,
35
+ Error :: StripPrefix ( inner) => write ! ( f, "Strip prefix error: {}" , inner) ,
36
+ Error :: WalkDir ( inner) => write ! ( f, "Walk dir error: {}" , inner) ,
37
+ }
38
+ }
39
+ }
40
+
41
+ impl std:: error:: Error for Error { }
42
+
31
43
/// Are the contents of two directories different?
32
44
///
33
45
/// # Examples
@@ -96,3 +108,21 @@ impl From<walkdir::Error> for Error {
96
108
Error :: WalkDir ( e)
97
109
}
98
110
}
111
+
112
+ #[ cfg( test) ]
113
+ mod tests {
114
+ use super :: * ;
115
+
116
+ #[ test]
117
+ fn test_display ( ) {
118
+ use std:: io:: ErrorKind ;
119
+
120
+ assert_eq ! (
121
+ format!(
122
+ "{}" ,
123
+ Error :: Io ( std:: io:: Error :: new( ErrorKind :: Other , "oh no!" ) )
124
+ ) ,
125
+ "I/O error: oh no!"
126
+ ) ;
127
+ }
128
+ }
You can’t perform that action at this time.
0 commit comments