cli: cleaner error handling
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
class UVError(Exception):
|
||||
"""Raised when running uv yields an exception"""
|
||||
|
||||
pass
|
||||
@@ -1,12 +1,12 @@
|
||||
import logging
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import copier
|
||||
import git
|
||||
|
||||
from core.exceptions import UVError
|
||||
from core.git import (
|
||||
assert_clean_repo,
|
||||
delete_local_branch,
|
||||
@@ -79,7 +79,11 @@ class ServiceCreator:
|
||||
registry_old.write_to_config()
|
||||
hla_names_old.write_to_config()
|
||||
switch_branch(repo, original_branch)
|
||||
raise e
|
||||
|
||||
if isinstance(e, UVError):
|
||||
pass
|
||||
else:
|
||||
raise e
|
||||
|
||||
def _render_new_service_templates(
|
||||
self,
|
||||
@@ -130,9 +134,9 @@ class ServiceCreator:
|
||||
logger.error(
|
||||
"The 'uv' command-line tool is not installed or not in your PATH.",
|
||||
)
|
||||
raise e
|
||||
raise UVError from 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
|
||||
raise UVError from e
|
||||
|
||||
Reference in New Issue
Block a user