File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ pub enum ConfigError {
46
46
NotFound ( String ) ,
47
47
48
48
/// Configuration path could not be parsed.
49
- PathParse ( nom :: error :: ErrorKind ) ,
49
+ PathParse { cause : Box < dyn Error + Send + Sync > } ,
50
50
51
51
/// Configuration could not be parsed from file.
52
52
FileParse {
@@ -187,7 +187,7 @@ impl fmt::Display for ConfigError {
187
187
match * self {
188
188
ConfigError :: Frozen => write ! ( f, "configuration is frozen" ) ,
189
189
190
- ConfigError :: PathParse ( ref kind ) => write ! ( f, "{}" , kind . description ( ) ) ,
190
+ ConfigError :: PathParse { ref cause } => write ! ( f, "{cause}" ) ,
191
191
192
192
ConfigError :: Message ( ref s) => write ! ( f, "{s}" ) ,
193
193
Original file line number Diff line number Diff line change @@ -17,10 +17,29 @@ impl FromStr for Expression {
17
17
type Err = ConfigError ;
18
18
19
19
fn from_str ( s : & str ) -> Result < Self > {
20
- parser:: from_str ( s) . map_err ( ConfigError :: PathParse )
20
+ parser:: from_str ( s) . map_err ( |e| ConfigError :: PathParse {
21
+ cause : Box :: new ( ParseError :: new ( e) ) ,
22
+ } )
21
23
}
22
24
}
23
25
26
+ #[ derive( Debug ) ]
27
+ struct ParseError ( String ) ;
28
+
29
+ impl ParseError {
30
+ fn new ( inner : nom:: error:: ErrorKind ) -> Self {
31
+ Self ( inner. description ( ) . to_owned ( ) )
32
+ }
33
+ }
34
+
35
+ impl std:: fmt:: Display for ParseError {
36
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
37
+ self . 0 . fmt ( f)
38
+ }
39
+ }
40
+
41
+ impl std:: error:: Error for ParseError { }
42
+
24
43
fn sindex_to_uindex ( index : isize , len : usize ) -> usize {
25
44
if index >= 0 {
26
45
index as usize
You can’t perform that action at this time.
0 commit comments