Merge "Remove use of str on exceptions"
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
import os.path
|
||||
import traceback
|
||||
|
||||
import six
|
||||
import webob
|
||||
from webob import exc
|
||||
|
||||
@@ -330,7 +331,7 @@ class AdminActionsController(wsgi.Controller):
|
||||
disk_over_commit = strutils.bool_from_string(disk_over_commit,
|
||||
strict=True)
|
||||
except ValueError as err:
|
||||
raise exc.HTTPBadRequest(explanation=str(err))
|
||||
raise exc.HTTPBadRequest(explanation=six.text_type(err))
|
||||
|
||||
instance = common.get_instance(self.compute_api, context, id,
|
||||
want_objects=True)
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
import webob
|
||||
|
||||
from nova.api.openstack import extensions
|
||||
@@ -83,7 +84,7 @@ class AssistedVolumeSnapshotsController(wsgi.Controller):
|
||||
delete_info = jsonutils.loads(delete_metadata['delete_info'])
|
||||
volume_id = delete_info['volume_id']
|
||||
except (KeyError, ValueError) as e:
|
||||
raise webob.exc.HTTPBadRequest(explanation=str(e))
|
||||
raise webob.exc.HTTPBadRequest(explanation=six.text_type(e))
|
||||
|
||||
try:
|
||||
self.compute_api.volume_snapshot_delete(context, volume_id,
|
||||
|
||||
@@ -419,7 +419,7 @@ class Controller(object):
|
||||
try:
|
||||
deleted = strutils.bool_from_string(deleted, strict=True)
|
||||
except ValueError as err:
|
||||
raise exc.HTTPBadRequest(explanation=str(err))
|
||||
raise exc.HTTPBadRequest(explanation=six.text_type(err))
|
||||
if updated_since:
|
||||
try:
|
||||
timeutils.parse_isotime(updated_since)
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
import netaddr
|
||||
from oslo.config import cfg
|
||||
import six
|
||||
import webob.exc
|
||||
|
||||
from nova.api.openstack import extensions
|
||||
@@ -147,7 +148,7 @@ class FloatingIPBulkController(object):
|
||||
else:
|
||||
return net.iter_hosts()
|
||||
except netaddr.AddrFormatError as exc:
|
||||
raise exception.InvalidInput(reason=str(exc))
|
||||
raise exception.InvalidInput(reason=six.text_type(exc))
|
||||
|
||||
|
||||
class Floating_ips_bulk(extensions.ExtensionDescriptor):
|
||||
|
||||
@@ -183,7 +183,7 @@ class NetworkController(wsgi.Controller):
|
||||
" with project %(project)s: %(message)s") %
|
||||
{"network": network_id or "",
|
||||
"project": project_id,
|
||||
"message": getattr(ex, "value", str(ex))})
|
||||
"message": getattr(ex, "value", ex)})
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
import netaddr
|
||||
import netaddr.core as netexc
|
||||
from oslo.config import cfg
|
||||
import six
|
||||
import webob
|
||||
from webob import exc
|
||||
|
||||
@@ -136,7 +137,7 @@ class NetworkController(object):
|
||||
self.network_api.delete(context, id)
|
||||
except exception.PolicyNotAuthorized as e:
|
||||
_rollback_quota(reservation)
|
||||
raise exc.HTTPForbidden(explanation=str(e))
|
||||
raise exc.HTTPForbidden(explanation=six.text_type(e))
|
||||
except exception.NetworkInUse as e:
|
||||
_rollback_quota(reservation)
|
||||
raise exc.HTTPConflict(explanation=e.format_message())
|
||||
@@ -196,7 +197,7 @@ class NetworkController(object):
|
||||
if CONF.enable_network_quota:
|
||||
QUOTAS.commit(context, reservation)
|
||||
except exception.PolicyNotAuthorized as e:
|
||||
raise exc.HTTPForbidden(explanation=str(e))
|
||||
raise exc.HTTPForbidden(explanation=six.text_type(e))
|
||||
except Exception:
|
||||
if CONF.enable_network_quota:
|
||||
QUOTAS.rollback(context, reservation)
|
||||
|
||||
@@ -278,7 +278,7 @@ class ServersController(wsgi.Controller):
|
||||
if not strutils.bool_from_string(all_tenants, True):
|
||||
del search_opts['all_tenants']
|
||||
except ValueError as err:
|
||||
raise exception.InvalidInput(str(err))
|
||||
raise exception.InvalidInput(six.text_type(err))
|
||||
|
||||
if 'all_tenants' in search_opts:
|
||||
policy.enforce(context, 'compute:get_all_tenants',
|
||||
|
||||
@@ -582,7 +582,7 @@ class Controller(wsgi.Controller):
|
||||
if not strutils.bool_from_string(all_tenants, True):
|
||||
del search_opts['all_tenants']
|
||||
except ValueError as err:
|
||||
raise exception.InvalidInput(str(err))
|
||||
raise exception.InvalidInput(six.text_type(err))
|
||||
|
||||
if 'all_tenants' in search_opts:
|
||||
policy.enforce(context, 'compute:get_all_tenants',
|
||||
|
||||
@@ -993,4 +993,4 @@ def safe_minidom_parse_string(xml_string):
|
||||
# NOTE(Vijaya Erukala): XML input such as
|
||||
# <?xml version="1.0" encoding="TF-8"?>
|
||||
# raises LookupError: unknown encoding: TF-8
|
||||
raise exception.MalformedRequestBody(reason=str(e))
|
||||
raise exception.MalformedRequestBody(reason=six.text_type(e))
|
||||
|
||||
Reference in New Issue
Block a user