diff --git a/obsws_python/events.py b/obsws_python/events.py index d002b58..5ac828e 100644 --- a/obsws_python/events.py +++ b/obsws_python/events.py @@ -7,7 +7,7 @@ from websocket import WebSocketTimeoutException from .baseclient import ObsClient from .callback import Callback -from .error import OBSSDKTimeoutError +from .error import OBSSDKError, OBSSDKTimeoutError from .subs import Subs """ @@ -27,9 +27,14 @@ class EventClient: defaultkwargs = {"subs": Subs.LOW_VOLUME} kwargs = defaultkwargs | kwargs self.base_client = ObsClient(**kwargs) - auth_status = self.base_client.authenticate() - if auth_status: - self.logger.info(f"Successfully identified {self} with the server using rpcVersion:{auth_status['d']['negotiatedRpcVersion']}") + try: + success = self.base_client.authenticate() + self.logger.info( + f"Successfully identified {self} with the server using RPC version:{success['negotiatedRpcVersion']}" + ) + except OBSSDKError as e: + self.logger.error(f"{type(e).__name__}: {e}") + raise self.callback = Callback() self.subscribe() diff --git a/obsws_python/reqs.py b/obsws_python/reqs.py index c363ead..5037913 100644 --- a/obsws_python/reqs.py +++ b/obsws_python/reqs.py @@ -17,9 +17,14 @@ class ReqClient: def __init__(self, **kwargs): self.logger = logger.getChild(self.__class__.__name__) self.base_client = ObsClient(**kwargs) - auth_status = self.base_client.authenticate() - if auth_status: - self.logger.info(f"Successfully identified {self} with the server using rpcVersion:{auth_status['d']['negotiatedRpcVersion']}") + try: + success = self.base_client.authenticate() + self.logger.info( + f"Successfully identified {self} with the server using RPC version:{success['negotiatedRpcVersion']}" + ) + except OBSSDKError as e: + self.logger.error(f"{type(e).__name__}: {e}") + raise def __enter__(self): return self