FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

request, response, code are attrs on RemoteError · python-webuntis/python-webuntis@05cb602 · GitHub

Commit 05cb602

Browse files
committed
request, response, code are attrs on RemoteError
1 parent bdaa37d commit 05cb602

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

‎webuntis/errors.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ class Error(Exception):
1313

1414
class RemoteError(Error, IOError):
1515
'''There was some kind of error while interacting with the server.'''
16-
pass
16+
17+
#: The decoded JSON request which lead to this error, if available.
18+
request = None
19+
20+
#: The decoded JSON response/result which lead to this error, if available.
21+
result = None
22+
23+
#: The error code, if available.
24+
code = None
1725

1826

1927
class MethodNotFoundError(RemoteError):

‎webuntis/utils/remote.py‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,11 @@ def _parse_error_code(request_body, result_body):
120120
message = ('Some error happened and there is no information provided '
121121
'what went wrong.')
122122

123-
cls = _errorcodes.get(code, errors.RemoteError)
124-
125-
raise cls(
126-
message,
127-
result_body,
128-
request_body
129-
)
130-
123+
exc = _errorcodes.get(code, errors.RemoteError)(message)
124+
exc.request = request_body
125+
exc.result = result_body
126+
exc.code = code
127+
raise exc
131128

132129
def _send_request(url, data, headers, http_session=None):
133130
'''Sends a POST request given the endpoint URL, JSON-encodable data,

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL