add custom error class + exit codes

This commit is contained in:
onyx-and-iris 2025-07-17 04:28:10 +01:00
parent 8349a196e8
commit 032b957670
2 changed files with 27 additions and 0 deletions

16
obsws_cli/enum.py Normal file
View File

@ -0,0 +1,16 @@
"""module for exit codes used in the application."""
from enum import IntEnum, auto
class ExitCode(IntEnum):
"""Exit codes for the application."""
SUCCESS = 0
ERROR = auto()
INVALID_ARGUMENT = auto()
INVALID_PARAMETER = auto()
NOT_FOUND = auto()
ALREADY_EXISTS = auto()
TIMEOUT = auto()
UNKNOWN_ERROR = auto()

11
obsws_cli/error.py Normal file
View File

@ -0,0 +1,11 @@
"""module containing error handling for OBS WebSocket CLI."""
class OBSWSCLIError(Exception):
"""Base class for OBS WebSocket CLI errors."""
def __init__(self, message: str, code: int = 1):
"""Initialize the error with a message and an optional code."""
super().__init__(message)
self.message = message
self.code = code