edtlib: improve error handling paths
Miscellaneous fixes discovered by inspection while type annotating the module. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
51d79808e4
commit
3d75f17d5e
1 changed files with 4 additions and 0 deletions
|
@ -190,6 +190,8 @@ class Binding:
|
|||
self._fname2path = fname2path
|
||||
|
||||
if raw is None:
|
||||
if path is None:
|
||||
_err("you must provide either a 'path' or a 'raw' argument")
|
||||
with open(path, encoding="utf-8") as f:
|
||||
raw = yaml.load(f, Loader=_BindingLoader)
|
||||
|
||||
|
@ -340,6 +342,8 @@ class Binding:
|
|||
|
||||
with open(path, encoding="utf-8") as f:
|
||||
contents = yaml.load(f, Loader=_BindingLoader)
|
||||
if not isinstance(contents, dict):
|
||||
_err(f'{path}: invalid contents, expected a mapping')
|
||||
|
||||
return self._merge_includes(contents, path)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue