mirror of
https://github.com/onyx-and-iris/obsws-python.git
synced 2024-11-24 13:50:52 +00:00
refactor OBSSDKRequestError
reword error section in README
This commit is contained in:
parent
013cf15024
commit
a7ef61018b
14
README.md
14
README.md
@ -128,13 +128,13 @@ def on_scene_created(data):
|
|||||||
|
|
||||||
### Errors
|
### Errors
|
||||||
|
|
||||||
A base error class `OBSSDKError` may be used to catch OBSSDK error types.
|
- `OBSSDKError`: Base error class.
|
||||||
|
- `OBSSDKTimeoutError`: Raised if a timeout occurs during sending/receiving a request or receiving an event
|
||||||
If a request returns an error code an `OBSSDKRequestError` will be raised.
|
- `OBSSDKRequestError`: Raised when a request returns an error code.
|
||||||
|
- The following attributes are available:
|
||||||
For a full list of status codes refer to [Codes](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#requeststatus)
|
- `req_name`: name of the request.
|
||||||
|
- `code`: request status code.
|
||||||
If a timeout occurs during sending/receiving a request or receiving an event an `OBSSDKTimeoutError` will be raised.
|
- For a full list of status codes refer to [Codes](https://github.com/obsproject/obs-websocket/blob/master/docs/generated/protocol.md#requeststatus)
|
||||||
|
|
||||||
### Logging
|
### Logging
|
||||||
|
|
||||||
|
@ -9,13 +9,10 @@ class OBSSDKTimeoutError(OBSSDKError):
|
|||||||
class OBSSDKRequestError(OBSSDKError):
|
class OBSSDKRequestError(OBSSDKError):
|
||||||
"""Exception raised when a request returns an error code"""
|
"""Exception raised when a request returns an error code"""
|
||||||
|
|
||||||
def __init__(self, req_name, code, message=None):
|
def __init__(self, req_name, code, comment):
|
||||||
self.req_name = req_name
|
self.req_name = req_name
|
||||||
self.code = code
|
self.code = code
|
||||||
self.message = " ".join(
|
message = f"Request {self.req_name} returned code {self.code}."
|
||||||
[
|
if comment:
|
||||||
f"Request {self.req_name} returned code {self.code}.",
|
message += f" With message: {comment}"
|
||||||
f"With message: {message}" if message else "",
|
super().__init__(message)
|
||||||
]
|
|
||||||
)
|
|
||||||
super().__init__(self.message)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user