Merge "Make remote error handling more robust"

This commit is contained in:
Jenkins 2017-09-06 22:37:26 +00:00 committed by Gerrit Code Review
commit 987f1502b6
2 changed files with 8 additions and 1 deletions

View File

@ -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

View File

@ -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)