scripts: west: improve error message on missing cache

In the west flash/debug commands, if the user gives an invalid build
directory, they'll get a stack trace instead of a helpful error
message when the cache can't be built.

Fix that.

Signed-off-by: Marti Bolivar <marti.bolivar@nordicsemi.no>
This commit is contained in:
Marti Bolivar 2019-06-10 14:11:27 -06:00 committed by Maureen Helm
parent 00c41ea893
commit 8718d5c84b
1 changed files with 4 additions and 1 deletions

View File

@ -171,7 +171,10 @@ def do_run_common(command, args, runner_args, cached_runner_var):
# make sure it supports the command.
cache_file = path.join(build_dir, args.cmake_cache or cmake.DEFAULT_CACHE)
cache = cmake.CMakeCache(cache_file)
try:
cache = cmake.CMakeCache(cache_file)
except FileNotFoundError:
log.die('no CMake cache found (expected one at {})'.format(cache_file))
board = cache['CACHED_BOARD']
available = cache.get_list('ZEPHYR_RUNNERS')
if not available: