summaryrefslogtreecommitdiff
path: root/designateclient
diff options
context:
space:
mode:
authorJens Harbott <j.harbott@x-ion.de>2017-09-01 10:45:10 +0000
committerJens Harbott <j.harbott@x-ion.de>2017-09-01 10:45:10 +0000
commit5b502b9f7849c7722d9c2737099b2e5d3380cda8 (patch)
treea589630a418b84b70907b4e93e3eb94488ba519e /designateclient
parent245ea8deac12c1d3ace14e8a9bc257b8fec3f587 (diff)
downloadpython-designateclient-5b502b9f7849c7722d9c2737099b2e5d3380cda8.tar.gz
Make remote error handling more robust
When a RemoteError is created, it is passed the complete content of the json response from the server. Thus is can happen that it contains unexpected entries, we should just ignore them. Change-Id: I2155d1d44432884f19ef926c02b9d0f99ade57d9 Closes-Bug: 1714460
Diffstat (limited to 'designateclient')
-rw-r--r--designateclient/exceptions.py2
-rw-r--r--designateclient/tests/test_exceptions.py7
2 files changed, 8 insertions, 1 deletions
diff --git a/designateclient/exceptions.py b/designateclient/exceptions.py
index 8b63e66..e220b97 100644
--- a/designateclient/exceptions.py
+++ b/designateclient/exceptions.py
@@ -36,7 +36,7 @@ class NoUniqueMatch(Base):
class RemoteError(Base):
def __init__(self, message=None, code=None, type=None, errors=None,
- request_id=None):
+ request_id=None, **ignore):
err_message = self._get_error_message(message, type, errors)
self.message = err_message
self.code = code
diff --git a/designateclient/tests/test_exceptions.py b/designateclient/tests/test_exceptions.py
index e307e9b..e016991 100644
--- a/designateclient/tests/test_exceptions.py
+++ b/designateclient/tests/test_exceptions.py
@@ -54,3 +54,10 @@ class RemoteErrorTestCase(base.TestCase):
self.response_dict['type'] = expected_msg
remote_err = exceptions.RemoteError(**self.response_dict)
self.assertEqual(expected_msg, remote_err.message)
+
+ def test_get_error_message_with_unknown_response(self):
+ expected_msg = 'invalid_object'
+ self.response_dict['message'] = expected_msg
+ self.response_dict['unknown'] = 'fake'
+ remote_err = exceptions.RemoteError(**self.response_dict)
+ self.assertEqual(expected_msg, remote_err.message)