mirror of
https://github.com/onyx-and-iris/obsws-python.git
synced 2024-11-22 04:40:53 +00:00
send now raises an OBSSDKRequestError
it is then logged and rethrown
This commit is contained in:
parent
f3e75c0ddf
commit
ffd215aadf
@ -1,7 +1,7 @@
|
||||
import logging
|
||||
|
||||
from .baseclient import ObsClient
|
||||
from .error import OBSSDKError
|
||||
from .error import OBSSDKError, OBSSDKRequestError
|
||||
from .util import as_dataclass
|
||||
|
||||
"""
|
||||
@ -43,14 +43,17 @@ class ReqClient:
|
||||
return type(self).__name__
|
||||
|
||||
def send(self, param, data=None, raw=False):
|
||||
try:
|
||||
response = self.base_client.req(param, data)
|
||||
if not response["requestStatus"]["result"]:
|
||||
error = (
|
||||
f"Request {response['requestType']} returned code {response['requestStatus']['code']}",
|
||||
raise OBSSDKRequestError(
|
||||
response["requestType"],
|
||||
response["requestStatus"]["code"],
|
||||
response["requestStatus"].get("comment"),
|
||||
)
|
||||
if "comment" in response["requestStatus"]:
|
||||
error += (f"With message: {response['requestStatus']['comment']}",)
|
||||
raise OBSSDKError("\n".join(error))
|
||||
except OBSSDKRequestError as e:
|
||||
self.logger.exception(f"{type(e).__name__}: {e}")
|
||||
raise
|
||||
if "responseData" in response:
|
||||
if raw:
|
||||
return response["responseData"]
|
||||
|
Loading…
Reference in New Issue
Block a user