@@ -42,7 +42,7 @@ pub fn process_file(yaml_file: &Path) -> Result<()> {
4242 root. get_str ( "_svd" ) ?
4343 . ok_or_else ( || anyhow ! ( "You must have an svd key in the root YAML file" ) ) ?,
4444 ) ,
45- ) ;
45+ ) ? ;
4646 let mut svdpath_out = svdpath. clone ( ) ;
4747 svdpath_out. set_extension ( "svd.patched" ) ;
4848 let f = File :: open ( svdpath) ?;
@@ -69,8 +69,8 @@ pub fn process_file(yaml_file: &Path) -> Result<()> {
6969}
7070
7171/// Gets the absolute path of relpath from the point of view of frompath.
72- fn abspath ( frompath : & Path , relpath : & Path ) -> PathBuf {
73- std:: fs:: canonicalize ( frompath. parent ( ) . unwrap ( ) . join ( relpath) ) . unwrap ( )
72+ fn abspath ( frompath : & Path , relpath : & Path ) -> Result < PathBuf , std :: io :: Error > {
73+ std:: fs:: canonicalize ( frompath. parent ( ) . unwrap ( ) . join ( relpath) )
7474}
7575
7676/// Recursively loads any included YAML files.
@@ -80,7 +80,9 @@ pub fn yaml_includes(parent: &mut Hash) -> Result<Vec<PathBuf>> {
8080 let self_path = PathBuf :: from ( parent. get ( & y_path) . unwrap ( ) . str ( ) ?) ;
8181 let inc = parent. get_vec ( "_include" ) ?. unwrap_or ( & Vec :: new ( ) ) . clone ( ) ;
8282 for relpath in inc {
83- let path = abspath ( & self_path, Path :: new ( relpath. as_str ( ) . unwrap ( ) ) ) ;
83+ let relpath = relpath. as_str ( ) . unwrap ( ) ;
84+ let path = abspath ( & self_path, Path :: new ( relpath) )
85+ . with_context ( || anyhow ! ( "Opening file \" {}\" from file {:?}" , relpath, self_path) ) ?;
8486 if included. contains ( & path) {
8587 continue ;
8688 }
0 commit comments