Skip to content

Commit

Permalink
manifest: handle missing top level manifest file
Browse files Browse the repository at this point in the history
Improve error handling to avoid dumping stack.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
  • Loading branch information
mbolivar-nordic committed May 23, 2023
1 parent 3463028 commit 279deb6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/west/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,15 @@ def get_option(option, default=None):

current_relpath = manifest_path / manifest_file
current_abspath = topdir_abspath / current_relpath
current_data = current_abspath.read_text(encoding='utf-8')
try:
current_data = current_abspath.read_text(encoding='utf-8')
except FileNotFoundError:
raise MalformedConfig(
f'file not found: manifest file {current_abspath} '
'(from configuration options '
f'manifest.path="{manifest_path_option}", '
f'manifest.file="{manifest_file}")')

current_repo_abspath = topdir_abspath / manifest_path

self.abspath = os.fspath(current_abspath)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ def test_bad_topdir_fails(tmp_workspace):
# Make sure we get expected failure using Manifest.from_topdir()
# with the topdir kwarg when no west.yml exists.

with pytest.raises(FileNotFoundError):
with pytest.raises(MalformedConfig):
MT(topdir=tmp_workspace)

def test_from_bad_topdir(tmpdir):
Expand Down

0 comments on commit 279deb6

Please sign in to comment.