in src/cli/utils/logging.py [0:0]
def handle_cli_error(f: F) -> F:
"""Decorator to handle CLI errors gracefully.
Wraps CLI command functions to catch any exceptions and display them nicely
to the user before exiting with a non-zero status code.
Args:
f: The CLI command function to wrap
Returns:
The wrapped function that handles errors
"""
@wraps(f)
def wrapper(*args: Any, **kwargs: Any) -> Any:
try:
return f(*args, **kwargs)
except KeyboardInterrupt:
console.print("\nOperation cancelled by user", style="yellow")
sys.exit(130) # Standard exit code for Ctrl+C
except Exception as e:
console.print(f"Error: {e!s}", style="bold red")
sys.exit(1)
return cast(F, wrapper)