add custom error class SlobsCliError

add exception group handling for all commands that may raise exceptions

add comments to for-else blocks
This commit is contained in:
2025-06-12 05:28:54 +01:00
parent a8bed0f4d9
commit d33c209d7c
7 changed files with 153 additions and 84 deletions

13
src/slobs_cli/errors.py Normal file
View File

@@ -0,0 +1,13 @@
import asyncclick as click
class SlobsCliError(click.ClickException):
"""Base class for all Slobs CLI errors."""
def __init__(self, message: str):
super().__init__(message)
self.exit_code = 1
def show(self):
"""Display the error message in red."""
click.secho(f"Error: {self.message}", fg="red", err=True)