| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,7 @@ def test_parse_result(self): | |||
| 14 | 14 | ||
| 15 | 15 | a = b = {'id': 2} | |
| 16 | 16 | self.assertRaisesRegex(webuntis.errors.RemoteError, | |
| 17 | - 'JSON-RPC', x, a, b) | ||
| 17 | + 'no information', x, a, b) | ||
| 18 | 18 | ||
| 19 | 19 | a = {'id': 2} | |
| 20 | 20 | b = {'id': 2, 'result': 'YESSIR'} | |
@@ -25,11 +25,11 @@ def test_parse_error_code(self): | |||
| 25 | 25 | ||
| 26 | 26 | a = b = {} | |
| 27 | 27 | self.assertRaisesRegex(webuntis.errors.RemoteError, | |
| 28 | - 'JSON-RPC', x, a, b) | ||
| 28 | + 'no information', x, a, b) | ||
| 29 | 29 | ||
| 30 | - b = {'error': {'code': 0, 'message': 'hello'}} | ||
| 30 | + b = {'error': {'code': 0, 'message': 'hello world'}} | ||
| 31 | 31 | self.assertRaisesRegex(webuntis.errors.RemoteError, | |
| 32 | - 'JSON-RPC', x, a, b) | ||
| 32 | + 'hello world', x, a, b) | ||
| 33 | 33 | ||
| 34 | 34 | for code, exc in webuntis.utils.remote._errorcodes.items(): | |
| 35 | 35 | self.assertRaises(exc, x, a, { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -108,15 +108,19 @@ def _parse_error_code(request_body, result_body): | |||
| 108 | 108 | log('error', result_body) | |
| 109 | 109 | try: | |
| 110 | 110 | error = result_body[u'error'] | |
| 111 | - exc = _errorcodes[error[u'code']](error[u'message']) | ||
| 111 | + code, message = error[u'code'], error[u'message'] | ||
| 112 | 112 | except KeyError: | |
| 113 | - exc = errors.RemoteError( | ||
| 114 | - ('Some JSON-RPC-ish error happened. Please report this to the ' | ||
| 115 | - 'developer so he can implement a proper handling.'), | ||
| 116 | - result_body, request_body | ||
| 117 | - ) | ||
| 113 | + code = None # None doesn't exist in_errorcodes | ||
| 114 | + message = ('Some error happened and there is no information provided ' | ||
| 115 | + 'what went wrong.') | ||
| 118 | 116 | ||
| 119 | - raise exc | ||
| 117 | + cls = _errorcodes.get(code, errors.RemoteError) | ||
| 118 | + | ||
| 119 | + raise cls( | ||
| 120 | + message, | ||
| 121 | + result_body, | ||
| 122 | + request_body | ||
| 123 | + ) | ||
| 120 | 124 | ||
| 121 | 125 | ||
| 122 | 126 | def _send_request(url, data, headers): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments