api: use more generic error member for exceptions
Rename the `API.exception` member to `API.error`, to make it more generic, so it can also be used for other sort of errors in the future. Also add a layer of additional structure with `type` and `data` members so different types of errors apart. Currently only `exception` is used. Adapt the tests in test/mod/test_api.py to check for the new structure and its content.
This commit is contained in:
parent
17fbe41b03
commit
f5d00dd043
3 changed files with 14 additions and 6 deletions
|
|
@ -144,7 +144,7 @@ class API(BaseAPI):
|
|||
self._output_pipe = None
|
||||
self.monitor = monitor
|
||||
self.metadata = {}
|
||||
self.exception = None
|
||||
self.error = None
|
||||
|
||||
@property
|
||||
def output(self):
|
||||
|
|
@ -187,7 +187,10 @@ class API(BaseAPI):
|
|||
sock.send({"type": "fd", "fd": 0}, fds=fds)
|
||||
|
||||
def _get_exception(self, message):
|
||||
self.exception = message["exception"]
|
||||
self.error = {
|
||||
"type": "exception",
|
||||
"data": message["exception"],
|
||||
}
|
||||
|
||||
def _message(self, msg, fds, sock):
|
||||
if msg["method"] == 'add-metadata':
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue