Remove usage of obsolete oslo.exception

Change-Id: I6f46f90bd74cc26fc01667e467e3dab38037eec3
Closes-Bug: #1208734
This commit is contained in:
Julien Danjou
2013-07-31 11:36:08 +02:00
parent a0633112ff
commit 0619385630
4 changed files with 3 additions and 146 deletions

View File

@@ -26,7 +26,6 @@ import cinder.api.openstack
from cinder.api.openstack import wsgi from cinder.api.openstack import wsgi
from cinder.api import xmlutil from cinder.api import xmlutil
from cinder import exception from cinder import exception
from cinder.openstack.common import exception as common_exception
from cinder.openstack.common import importutils from cinder.openstack.common import importutils
from cinder.openstack.common import log as logging from cinder.openstack.common import log as logging
import cinder.policy import cinder.policy
@@ -373,7 +372,7 @@ def load_standard_extensions(ext_mgr, logger, path, package, ext_list=None):
(package, relpkg, dname)) (package, relpkg, dname))
try: try:
ext = importutils.import_class(ext_name) ext = importutils.import_class(ext_name)
except common_exception.NotFound: except ImportError:
# extension() doesn't exist on it, so we'll explore # extension() doesn't exist on it, so we'll explore
# the directory for ourselves # the directory for ourselves
subdirs.append(dname) subdirs.append(dname)

View File

@@ -29,7 +29,6 @@ import sys
from oslo.config import cfg from oslo.config import cfg
import webob.exc import webob.exc
from cinder.openstack.common import exception as com_exception
from cinder.openstack.common import log as logging from cinder.openstack.common import log as logging
@@ -78,7 +77,8 @@ class ProcessExecutionError(IOError):
IOError.__init__(self, message) IOError.__init__(self, message)
Error = com_exception.Error class Error(Exception):
pass
class CinderException(Exception): class CinderException(Exception):

View File

@@ -1,141 +0,0 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2011 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""
Exceptions common to OpenStack projects
"""
import logging
from cinder.openstack.common.gettextutils import _
_FATAL_EXCEPTION_FORMAT_ERRORS = False
class Error(Exception):
def __init__(self, message=None):
super(Error, self).__init__(message)
class ApiError(Error):
def __init__(self, message='Unknown', code='Unknown'):
self.message = message
self.code = code
super(ApiError, self).__init__('%s: %s' % (code, message))
class NotFound(Error):
pass
class UnknownScheme(Error):
msg = "Unknown scheme '%s' found in URI"
def __init__(self, scheme):
msg = self.__class__.msg % scheme
super(UnknownScheme, self).__init__(msg)
class BadStoreUri(Error):
msg = "The Store URI %s was malformed. Reason: %s"
def __init__(self, uri, reason):
msg = self.__class__.msg % (uri, reason)
super(BadStoreUri, self).__init__(msg)
class Duplicate(Error):
pass
class NotAuthorized(Error):
pass
class NotEmpty(Error):
pass
class Invalid(Error):
pass
class BadInputError(Exception):
"""Error resulting from a client sending bad input to a server"""
pass
class MissingArgumentError(Error):
pass
class DatabaseMigrationError(Error):
pass
class ClientConnectionError(Exception):
"""Error resulting from a client connecting to a server"""
pass
def wrap_exception(f):
def _wrap(*args, **kw):
try:
return f(*args, **kw)
except Exception as e:
if not isinstance(e, Error):
#exc_type, exc_value, exc_traceback = sys.exc_info()
logging.exception(_('Uncaught exception'))
#logging.error(traceback.extract_stack(exc_traceback))
raise Error(str(e))
raise
_wrap.func_name = f.func_name
return _wrap
class OpenstackException(Exception):
"""Base Exception class.
To correctly use this class, inherit from it and define
a 'message' property. That message will get printf'd
with the keyword arguments provided to the constructor.
"""
message = "An unknown exception occurred"
def __init__(self, **kwargs):
try:
self._error_string = self.message % kwargs
except Exception as e:
if _FATAL_EXCEPTION_FORMAT_ERRORS:
raise e
else:
# at least get the core message out if something happened
self._error_string = self.message
def __str__(self):
return self._error_string
class MalformedRequestBody(OpenstackException):
message = "Malformed message body: %(reason)s"
class InvalidContentType(OpenstackException):
message = "Invalid content type %(content_type)s"

View File

@@ -4,7 +4,6 @@
module=context module=context
module=db module=db
module=db.sqlalchemy module=db.sqlalchemy
module=exception
module=excutils module=excutils
module=fileutils module=fileutils
module=flakes module=flakes