Merge "Raise a more specific exception on nova 400 errors"
This commit is contained in:
commit
5458e569fa
@ -27,6 +27,7 @@ import time
|
||||
from decorator import decorator
|
||||
from heatclient import exc as heat_exc
|
||||
from neutronclient.common import exceptions as neutron_exc
|
||||
from novaclient import exceptions as nova_exc
|
||||
|
||||
from shade import _log
|
||||
from shade import exc
|
||||
@ -481,6 +482,10 @@ def shade_exceptions(error_message=None):
|
||||
yield
|
||||
except exc.OpenStackCloudException:
|
||||
raise
|
||||
except nova_exc.BadRequest as e:
|
||||
if error_message is None:
|
||||
error_message = str(e)
|
||||
raise exc.OpenStackCloudBadRequest(error_message)
|
||||
except Exception as e:
|
||||
if error_message is None:
|
||||
error_message = str(e)
|
||||
|
10
shade/exc.py
10
shade/exc.py
@ -73,6 +73,14 @@ class OpenStackCloudHTTPError(OpenStackCloudException, _rex.HTTPError):
|
||||
_rex.HTTPError.__init__(self, *args, **kwargs)
|
||||
|
||||
|
||||
class OpenStackCloudBadRequest(OpenStackCloudHTTPError):
|
||||
"""There is something wrong with the request payload.
|
||||
|
||||
Possible reasons can include malformed json or invalid values to parameters
|
||||
such as flavorRef to a server create.
|
||||
"""
|
||||
|
||||
|
||||
class OpenStackCloudURINotFound(OpenStackCloudHTTPError):
|
||||
pass
|
||||
|
||||
@ -98,5 +106,7 @@ def raise_from_response(response):
|
||||
# before
|
||||
if response.status_code == 404:
|
||||
raise OpenStackCloudURINotFound(msg, response=response)
|
||||
elif response.status_code == 400:
|
||||
raise OpenStackCloudBadRequest(msg, response=response)
|
||||
if msg:
|
||||
raise OpenStackCloudHTTPError(msg, response=response)
|
||||
|
Loading…
x
Reference in New Issue
Block a user