Browse Source

scripts: zephyr_module: handle expected west errors

Errors can occur if the user's workspace is not set up properly.
Output a better error message instead of dumping stack in these cases.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
pull/58060/head
Martí Bolívar 2 years ago committed by Carles Cufí
parent
commit
ce2a7d9a1a
  1. 7
      scripts/zephyr_module.py

7
scripts/zephyr_module.py

@ -521,7 +521,9 @@ def west_projects(manifest = None): @@ -521,7 +521,9 @@ def west_projects(manifest = None):
# (and thus maybe not installed)
# if user is providing a specific modules list.
try:
from west.manifest import Manifest
from west.manifest import Manifest, \
ManifestImportFailed, MalformedManifest, ManifestVersionError
from west.configuration import MalformedConfig
from west.util import WestNotFound
from west.version import __version__ as WestVersion
except ImportError:
@ -539,6 +541,9 @@ def west_projects(manifest = None): @@ -539,6 +541,9 @@ def west_projects(manifest = None):
projects = manifest.get_projects([])
manifest_path = manifest.path
return {'manifest_path': manifest_path, 'projects': projects}
except (ManifestImportFailed, MalformedManifest,
ManifestVersionError, MalformedConfig) as e:
sys.exit(f'ERROR: {e}')
except WestNotFound:
# Only accept WestNotFound, meaning we are not in a west
# workspace. Such setup is allowed, as west may be installed

Loading…
Cancel
Save