Skip to content

Commit

Permalink
Do not crash if the server does not provide py_exception
Browse files Browse the repository at this point in the history
  • Loading branch information
themylogin committed Jul 10, 2024
1 parent acfabef commit a935df2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion truenas_api_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,8 @@ def _parse_error(self, error: dict, call: Call):
if self._py_exceptions and code in [JSONRPCError.INVALID_PARAMS, JSONRPCError.TRUENAS_CALL_ERROR]:
data = error['data']
call.error = ClientException(data['reason'], data['error'], data['trace'], data['extra'])
call.py_exception = pickle.loads(b64decode(error['data']['py_exception']))
if data.get('py_exception'):
call.py_exception = pickle.loads(b64decode(data['py_exception']))
elif code == JSONRPCError.INVALID_PARAMS:
call.error = ValidationErrors(error['data']['extra'])
elif code == JSONRPCError.TRUENAS_CALL_ERROR:
Expand Down

0 comments on commit a935df2

Please sign in to comment.