mirror of
https://github.com/onyx-and-iris/slobs-cli.git
synced 2026-04-21 00:13:39 +00:00
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:
13
src/slobs_cli/errors.py
Normal file
13
src/slobs_cli/errors.py
Normal 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)
|
||||
Reference in New Issue
Block a user