Merge "Raise NotFoundException for 404s"
This commit is contained in:
@@ -75,6 +75,11 @@ class HttpException(SDKException):
|
||||
return self.__unicode__()
|
||||
|
||||
|
||||
class NotFoundException(HttpException):
|
||||
"""HTTP 404 Not Found."""
|
||||
pass
|
||||
|
||||
|
||||
class MethodNotSupported(SDKException):
|
||||
"""The resource does not support this operation type."""
|
||||
pass
|
||||
|
||||
@@ -305,7 +305,7 @@ class TestTransport(base.TestTransportBase):
|
||||
|
||||
mock_req.get(self.TEST_URL, status_code=status)
|
||||
|
||||
exc = self.assertRaises(exceptions.HttpException, xport.get,
|
||||
exc = self.assertRaises(exceptions.NotFoundException, xport.get,
|
||||
self.TEST_URL)
|
||||
self.assertEqual(status, exc.status_code)
|
||||
|
||||
|
||||
@@ -262,10 +262,15 @@ class Transport(requests.Session):
|
||||
try:
|
||||
resp.raise_for_status()
|
||||
except requests.RequestException as e:
|
||||
raise exceptions.HttpException(
|
||||
six.text_type(e),
|
||||
details=self._parse_error_response(resp),
|
||||
status_code=resp.status_code)
|
||||
if resp.status_code == 404:
|
||||
exc_type = exceptions.NotFoundException
|
||||
else:
|
||||
exc_type = exceptions.HttpException
|
||||
|
||||
raise exc_type(six.text_type(e),
|
||||
details=self._parse_error_response(resp),
|
||||
status_code=resp.status_code)
|
||||
|
||||
if accept == JSON:
|
||||
try:
|
||||
resp.body = resp.json()
|
||||
|
||||
Reference in New Issue
Block a user