Raise a new exception NotImplemented for HTTP501
In _error_checker(), both HTTP500 and 501 are converted to the same exception ServerFault. In addition, some method which extracts error message raises a specific exception IdentityError without considering HTTP code. This patch adds a new exception NotImplemented and uses it for HTTP501 so that we can know which error response is returned from a server. Change-Id: Ic8fc216377942619f11a2462b79d0597071ac294
This commit is contained in:
parent
938e3330e2
commit
43a694a988
|
@ -539,15 +539,17 @@ class RestClient(object):
|
|||
message = resp_body['cloudServersFault']['message']
|
||||
elif 'computeFault' in resp_body:
|
||||
message = resp_body['computeFault']['message']
|
||||
elif 'error' in resp_body: # Keystone errors
|
||||
elif 'error' in resp_body:
|
||||
message = resp_body['error']['message']
|
||||
raise exceptions.IdentityError(message)
|
||||
elif 'message' in resp_body:
|
||||
message = resp_body['message']
|
||||
else:
|
||||
message = resp_body
|
||||
|
||||
raise exceptions.ServerFault(message)
|
||||
if resp.status == 501:
|
||||
raise exceptions.NotImplemented(message)
|
||||
else:
|
||||
raise exceptions.ServerFault(message)
|
||||
|
||||
if resp.status >= 400:
|
||||
raise exceptions.UnexpectedResponseCode(str(resp.status))
|
||||
|
|
|
@ -152,6 +152,10 @@ class ServerFault(RestClientException):
|
|||
message = "Got server fault"
|
||||
|
||||
|
||||
class NotImplemented(RestClientException):
|
||||
message = "Got NotImplemented error"
|
||||
|
||||
|
||||
class ImageFault(TempestException):
|
||||
message = "Got image fault"
|
||||
|
||||
|
|
|
@ -351,7 +351,7 @@ class TestRestClientErrorCheckerJSON(base.TestCase):
|
|||
**self.set_data("500"))
|
||||
|
||||
def test_response_501_with_text(self):
|
||||
self.assertRaises(exceptions.ServerFault,
|
||||
self.assertRaises(exceptions.NotImplemented,
|
||||
self.rest_client._error_checker,
|
||||
**self.set_data("501"))
|
||||
|
||||
|
@ -363,7 +363,7 @@ class TestRestClientErrorCheckerJSON(base.TestCase):
|
|||
|
||||
def test_response_501_with_dict(self):
|
||||
r_body = '{"resp_body": {"err": "fake_resp_body"}}'
|
||||
self.assertRaises(exceptions.ServerFault,
|
||||
self.assertRaises(exceptions.NotImplemented,
|
||||
self.rest_client._error_checker,
|
||||
**self.set_data("501", r_body=r_body))
|
||||
|
||||
|
|
Loading…
Reference in New Issue