From 8718d5c84b027d791745fa8c4ee58f8977699d5c Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Mon, 10 Jun 2019 14:11:27 -0600 Subject: [PATCH] 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 --- scripts/west_commands/run_common.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/west_commands/run_common.py b/scripts/west_commands/run_common.py index ff485fe91a3..03ef8b3b77f 100644 --- a/scripts/west_commands/run_common.py +++ b/scripts/west_commands/run_common.py @@ -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: