From fe2f7a5f91f7b2e55affc949e7fff99691b86c8d Mon Sep 17 00:00:00 2001 From: Benjamin Labrecque Date: Tue, 7 Jul 2026 11:58:08 +0200 Subject: [PATCH] chore: cli better error handling --- cli/src/core/service_creator.py | 34 ++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/cli/src/core/service_creator.py b/cli/src/core/service_creator.py index a1ded2e..8efc064 100644 --- a/cli/src/core/service_creator.py +++ b/cli/src/core/service_creator.py @@ -112,15 +112,27 @@ class ServiceCreator: project_path = Path(SERVICE_DEST_DIR / service.dir_name).resolve() logger.info(f"Generating uv.lock inside: {project_path}") - result = subprocess.run( - ["uv", "lock"], - cwd=project_path, # Changes the working directory for the command - capture_output=True, # Captures stdout and stderr - text=True, # Returns strings instead of raw bytes - check=True, # Raises CalledProcessError if the exit code is non-zero - ) + try: + result = subprocess.run( + ["uv", "lock"], + cwd=project_path, # Changes the working directory for the command + capture_output=True, # Captures stdout and stderr + text=True, # Returns strings instead of raw bytes + check=True, # Raises CalledProcessError if the exit code is non-zero + ) - logger.info("Success! uv.lock has been generated/updated.") - if result.stderr: - # uv prints its progress and resolution metrics to stderr - logger.warning(result.stderr.strip()) + logger.info("Success! uv.lock has been generated/updated.") + if result.stderr: + # uv prints its progress and resolution metrics to stderr + logger.warning(result.stderr.strip()) + + except FileNotFoundError as e: + logger.error( + "The 'uv' command-line tool is not installed or not in your PATH.", + ) + raise e + except subprocess.CalledProcessError as e: + logger.error("'uv lock' failed to execute successfully.") + logger.error(f"Exit Code: {e.returncode}") + logger.error(f"Details:\n{e.stderr}") + raise e