From: Julien Danjou Date: Wed, 31 Jul 2013 09:36:08 +0000 (+0200) Subject: Remove usage of obsolete oslo.exception X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=061938563097241983b70fc6b85e1c196dfebfeb;p=openstack-build%2Fcinder-build.git Remove usage of obsolete oslo.exception Change-Id: I6f46f90bd74cc26fc01667e467e3dab38037eec3 Closes-Bug: #1208734 --- diff --git a/cinder/api/extensions.py b/cinder/api/extensions.py index da6042b65..5ed427420 100644 --- a/cinder/api/extensions.py +++ b/cinder/api/extensions.py @@ -26,7 +26,6 @@ import cinder.api.openstack from cinder.api.openstack import wsgi from cinder.api import xmlutil from cinder import exception -from cinder.openstack.common import exception as common_exception from cinder.openstack.common import importutils from cinder.openstack.common import log as logging import cinder.policy @@ -373,7 +372,7 @@ def load_standard_extensions(ext_mgr, logger, path, package, ext_list=None): (package, relpkg, dname)) try: ext = importutils.import_class(ext_name) - except common_exception.NotFound: + except ImportError: # extension() doesn't exist on it, so we'll explore # the directory for ourselves subdirs.append(dname) diff --git a/cinder/exception.py b/cinder/exception.py index 044f3ad25..bb53b1bd7 100644 --- a/cinder/exception.py +++ b/cinder/exception.py @@ -29,7 +29,6 @@ import sys from oslo.config import cfg import webob.exc -from cinder.openstack.common import exception as com_exception from cinder.openstack.common import log as logging @@ -78,7 +77,8 @@ class ProcessExecutionError(IOError): IOError.__init__(self, message) -Error = com_exception.Error +class Error(Exception): + pass class CinderException(Exception): diff --git a/cinder/openstack/common/exception.py b/cinder/openstack/common/exception.py deleted file mode 100644 index ecaf27533..000000000 --- a/cinder/openstack/common/exception.py +++ /dev/null @@ -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" diff --git a/openstack-common.conf b/openstack-common.conf index 2a183610c..80504131e 100644 --- a/openstack-common.conf +++ b/openstack-common.conf @@ -4,7 +4,6 @@ module=context module=db module=db.sqlalchemy -module=exception module=excutils module=fileutils module=flakes