File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -204,7 +204,7 @@ impl Config {
204204 value
205205 . clone ( )
206206 . try_into ( )
207- . with_context ( || "Failed to deserialize `{name}`" )
207+ . with_context ( || format ! ( "Failed to deserialize `{name}`" ) )
208208 } )
209209 . transpose ( )
210210 }
@@ -1147,4 +1147,18 @@ mod tests {
11471147 assert_eq ! ( json!( TextDirection :: RightToLeft ) , json!( "rtl" ) ) ;
11481148 assert_eq ! ( json!( TextDirection :: LeftToRight ) , json!( "ltr" ) ) ;
11491149 }
1150+
1151+ #[ test]
1152+ fn get_deserialize_error ( ) {
1153+ let src = r#"
1154+ [preprocessor.foo]
1155+ x = 123
1156+ "# ;
1157+ let cfg = Config :: from_str ( src) . unwrap ( ) ;
1158+ let err = cfg. get :: < String > ( "preprocessor.foo.x" ) . unwrap_err ( ) ;
1159+ assert_eq ! (
1160+ err. to_string( ) ,
1161+ "Failed to deserialize `preprocessor.foo.x`"
1162+ ) ;
1163+ }
11501164}
You can’t perform that action at this time.
0 commit comments