From 032b957670c0040f896354557b292ac057480aea Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Thu, 17 Jul 2025 04:28:10 +0100 Subject: [PATCH] add custom error class + exit codes --- obsws_cli/enum.py | 16 ++++++++++++++++ obsws_cli/error.py | 11 +++++++++++ 2 files changed, 27 insertions(+) create mode 100644 obsws_cli/enum.py create mode 100644 obsws_cli/error.py diff --git a/obsws_cli/enum.py b/obsws_cli/enum.py new file mode 100644 index 0000000..fca0fb5 --- /dev/null +++ b/obsws_cli/enum.py @@ -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() diff --git a/obsws_cli/error.py b/obsws_cli/error.py new file mode 100644 index 0000000..33efaaa --- /dev/null +++ b/obsws_cli/error.py @@ -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