mirror of
https://github.com/onyx-and-iris/obsws-python.git
synced 2024-11-22 12:50:53 +00:00
onyx-and-iris
f3e75c0ddf
OBSSDKTimeoutError and OBSSDKRequestError subclass it req_name and error code set as error class attributes.
22 lines
627 B
Python
22 lines
627 B
Python
class OBSSDKError(Exception):
|
|
"""Base class for OBSSDK errors"""
|
|
|
|
|
|
class OBSSDKTimeoutError(OBSSDKError):
|
|
"""Exception raised when a connection times out"""
|
|
|
|
|
|
class OBSSDKRequestError(OBSSDKError):
|
|
"""Exception raised when a request returns an error code"""
|
|
|
|
def __init__(self, req_name, code, message=None):
|
|
self.req_name = req_name
|
|
self.code = code
|
|
self.message = " ".join(
|
|
[
|
|
f"Request {self.req_name} returned code {self.code}.",
|
|
f"With message: {message}" if message else "",
|
|
]
|
|
)
|
|
super().__init__(self.message)
|