Skip to content

Commit

Permalink
manifest: improve ManifestImportError __str__
Browse files Browse the repository at this point in the history
Try to provide more helpful text.

Signed-off-by: Martí Bolívar <[email protected]>
  • Loading branch information
mbolivar-nordic committed May 5, 2023
1 parent b6b130b commit de85904
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/west/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,8 +843,9 @@ def add_argument(self, *args, **kwargs):
def error(self, message):
if self.west_app and self.west_app.mle:
# If we have a known WestApp instance and the manifest
# failed to load, then try to specialize the error message
# to handle west-specific situations.
# failed to load, then try to specialize the generic error
# message we're getting from argparse to handle west-specific
# errors better.

app = self.west_app
mle = self.west_app.mle
Expand Down
12 changes: 7 additions & 5 deletions src/west/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,12 +565,14 @@ def __init__(self, project: Optional['Project'], imp: Any):
self.imp = imp

def __str__(self):
if self.project is not None:
return (f'ManifestImportFailed: project {self.project} '
f'value {self.imp}')
if self.project is None:
# This happens when imports fail in the manifest repository
return (f'cannot import {self.imp}; is it present '
'in your manifest repository?')
else:
return (f'ManifestImportFailed: manifest repository '
f'value {self.imp}')
return (f'project {self.project.name_and_path}: '
f'cannot import contents of {self.imp}; '
'do you need to run "west update"?')


class ManifestVersionError(Exception):
Expand Down

0 comments on commit de85904

Please sign in to comment.