Navigation Menu

Skip to content

Commit

Permalink
Renamed "exceptions" module to "errors"
Browse files Browse the repository at this point in the history
Changes exceptions.py into error.py

Renaming exception-related code to errors
because most of the conditions handled by
marconi are errorneous rather than exceptional.

Closes-Bug:#1232074

Change-Id: Ie3509236b07a372a44d97f97e5f3fe183b409606
  • Loading branch information
cindy committed Oct 30, 2013
1 parent 4f5de4b commit 5624bf1
Show file tree
Hide file tree
Showing 40 changed files with 183 additions and 182 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion marconi/common/transport/wsgi/utils.py
Expand Up @@ -19,7 +19,7 @@

from marconi.openstack.common import log
from marconi.queues.transport import utils as json_utils
from marconi.queues.transport.wsgi import exceptions as wsgi_errors
from marconi.queues.transport.wsgi import errors as wsgi_errors

LOG = log.getLogger(__name__)

Expand Down
8 changes: 4 additions & 4 deletions marconi/proxy/base.py
Expand Up @@ -19,7 +19,7 @@
from marconi.common import access
from marconi.common.cache import cache as oslo_cache
from marconi.common import decorators
from marconi.common import exceptions
from marconi.common import errors
from marconi.openstack.common import log
from marconi.proxy import transport # NOQA

Expand Down Expand Up @@ -68,7 +68,7 @@ def storage(self):
return mgr.driver
except RuntimeError as exc:
LOG.exception(exc)
raise exceptions.InvalidDriver(exc)
raise errors.InvalidDriver(exc)

@decorators.lazy_property(write=False)
def cache(self):
Expand All @@ -78,7 +78,7 @@ def cache(self):
return mgr
except RuntimeError as exc:
LOG.exception(exc)
raise exceptions.InvalidDriver(exc)
raise errors.InvalidDriver(exc)

@decorators.lazy_property(write=False)
def transport(self):
Expand All @@ -92,7 +92,7 @@ def transport(self):
return mgr.driver
except RuntimeError as exc:
LOG.exception(exc)
raise exceptions.InvalidDriver(exc)
raise errors.InvalidDriver(exc)

def run(self):
self.transport.listen()
2 changes: 1 addition & 1 deletion marconi/proxy/storage/__init__.py
@@ -1,7 +1,7 @@
"""Marconi proxy storage drivers"""

from marconi.proxy.storage import base
from marconi.proxy.storage import exceptions # NOQA
from marconi.proxy.storage import errors # NOQA

# NOTE(cpp-cabrera): Hoist classes into package namespace
CatalogueBase = base.CatalogueBase
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions marconi/proxy/storage/memory/catalogue.py
Expand Up @@ -15,7 +15,7 @@
import six

from marconi.proxy.storage import base
from marconi.proxy.storage import exceptions
from marconi.proxy.storage import errors


def _idx(project, queue):
Expand All @@ -37,7 +37,7 @@ def get(self, project, queue):
try:
entry = self._col[_idx(project, queue)]
except KeyError:
raise exceptions.EntryNotFound(project, queue)
raise errors.EntryNotFound(project, queue)

return _normalize(entry)

Expand Down
6 changes: 3 additions & 3 deletions marconi/proxy/storage/memory/partitions.py
Expand Up @@ -16,7 +16,7 @@
import six

from marconi.proxy.storage import base
from marconi.proxy.storage import exceptions
from marconi.proxy.storage import errors


class PartitionsController(base.PartitionsBase):
Expand All @@ -33,7 +33,7 @@ def get(self, name):
try:
entry = self._col[name]
except KeyError:
raise exceptions.PartitionNotFound(name)
raise errors.PartitionNotFound(name)

return _normalize(entry)

Expand All @@ -52,7 +52,7 @@ def update(self, name, **kwargs):
try:
self._col[name].update(fields)
except KeyError:
raise exceptions.PartitionNotFound(name)
raise errors.PartitionNotFound(name)

def delete(self, name):
try:
Expand Down
4 changes: 2 additions & 2 deletions marconi/proxy/storage/mongodb/catalogue.py
Expand Up @@ -29,7 +29,7 @@

import marconi.openstack.common.log as logging
from marconi.proxy.storage import base
from marconi.proxy.storage import exceptions
from marconi.proxy.storage import errors as storage_errors
from marconi.queues.storage.mongodb import utils


Expand Down Expand Up @@ -64,7 +64,7 @@ def get(self, project, queue):
fields=fields)

if entry is None:
raise exceptions.EntryNotFound(project, queue)
raise storage_errors.EntryNotFound(project, queue)

return _normalize(entry)

Expand Down
6 changes: 3 additions & 3 deletions marconi/proxy/storage/mongodb/partitions.py
Expand Up @@ -25,7 +25,7 @@
"""

from marconi.proxy.storage import base
from marconi.proxy.storage import exceptions
from marconi.proxy.storage import errors
from marconi.queues.storage.mongodb import utils


Expand Down Expand Up @@ -55,7 +55,7 @@ def get(self, name):
fields=fields)

if partition is None:
raise exceptions.PartitionNotFound(name)
raise errors.PartitionNotFound(name)

return _normalize(partition)

Expand Down Expand Up @@ -94,7 +94,7 @@ def update(self, name, **kwargs):
{'$set': fields},
upsert=False)
if not res['updatedExisting']:
raise exceptions.PartitionNotFound(name)
raise errors.PartitionNotFound(name)


def _normalize(entry):
Expand Down
4 changes: 2 additions & 2 deletions marconi/proxy/transport/wsgi/catalogue.py
Expand Up @@ -21,7 +21,7 @@
import falcon

from marconi.openstack.common import log
from marconi.proxy.storage import exceptions
from marconi.proxy.storage import errors
from marconi.proxy.utils import helpers


Expand Down Expand Up @@ -66,7 +66,7 @@ def on_get(self, request, response, queue):
entry = None
try:
entry = self._catalogue.get(project, queue)
except exceptions.EntryNotFound:
except errors.EntryNotFound:
LOG.debug('Entry not found')
raise falcon.HTTPNotFound()

Expand Down
8 changes: 4 additions & 4 deletions marconi/proxy/transport/wsgi/partitions.py
Expand Up @@ -34,10 +34,10 @@

from marconi.common.transport.wsgi import utils
from marconi.openstack.common import log
from marconi.proxy.storage import exceptions
from marconi.proxy.storage import errors
from marconi.proxy.transport import schema
from marconi.proxy.utils import lookup
from marconi.queues.transport.wsgi import exceptions as wsgi_errors
from marconi.queues.transport.wsgi import errors as wsgi_errors


LOG = log.getLogger(__name__)
Expand Down Expand Up @@ -96,7 +96,7 @@ def on_get(self, request, response, partition):
data = None
try:
data = self._ctrl.get(partition)
except exceptions.PartitionNotFound as ex:
except errors.PartitionNotFound as ex:
LOG.exception(ex)
raise falcon.HTTPNotFound()

Expand Down Expand Up @@ -163,6 +163,6 @@ def on_patch(self, request, response, partition):
and v is not None)

self._ctrl.update(partition, **fields)
except exceptions.PartitionNotFound as ex:
except errors.PartitionNotFound as ex:
LOG.exception(ex)
raise falcon.HTTPNotFound()
4 changes: 2 additions & 2 deletions marconi/proxy/transport/wsgi/queues.py
Expand Up @@ -42,7 +42,7 @@
)
from marconi.queues.storage import base as storage
from marconi.queues.transport import validation as validate
from marconi.queues.transport.wsgi import exceptions as wsgi_exceptions
from marconi.queues.transport.wsgi import errors as wsgi_errors


LOG = log.getLogger(__name__)
Expand Down Expand Up @@ -81,7 +81,7 @@ def on_get(self, request, response):
try:
validate.queue_listing(limit=limit)
except validate.ValidationFailed as ex:
raise wsgi_exceptions.HTTPBadRequestAPI(six.text_type(ex))
raise wsgi_errors.HTTPBadRequestAPI(six.text_type(ex))

for queue in self._catalogue.list(project):
queue_name = queue['name']
Expand Down
6 changes: 3 additions & 3 deletions marconi/proxy/utils/lookup.py
Expand Up @@ -18,7 +18,7 @@
import msgpack

from marconi.openstack.common import log
from marconi.proxy.storage import exceptions
from marconi.proxy.storage import errors


LOG = log.getLogger(__name__)
Expand Down Expand Up @@ -56,7 +56,7 @@ def try_cache_entry(project, queue, catalogue_controller, cache):

try:
name = catalogue_controller.get(project, queue)['partition']
except exceptions.EntryNotFound:
except errors.EntryNotFound:
return None

cache.set(key, name)
Expand Down Expand Up @@ -156,7 +156,7 @@ def hosts(name, partitions_controller, cache):

try:
hosts = partitions_controller.get(name)['hosts']
except exceptions.PartitionNotFound:
except errors.PartitionNotFound:
LOG.debug('Partition not in primary storage: ' + name)
return None

Expand Down
6 changes: 3 additions & 3 deletions marconi/queues/bootstrap.py
Expand Up @@ -18,7 +18,7 @@

from marconi.common.cache import cache as oslo_cache
from marconi.common import decorators
from marconi.common import exceptions
from marconi.common import errors
from marconi.openstack.common import log
from marconi.queues.storage import pipeline
from marconi.queues.storage import sharding
Expand Down Expand Up @@ -82,7 +82,7 @@ def cache(self):
return mgr
except RuntimeError as exc:
LOG.exception(exc)
raise exceptions.InvalidDriver(exc)
raise errors.InvalidDriver(exc)

@decorators.lazy_property(write=False)
def transport(self):
Expand All @@ -99,7 +99,7 @@ def transport(self):
return mgr.driver
except RuntimeError as exc:
LOG.exception(exc)
raise exceptions.InvalidDriver(exc)
raise errors.InvalidDriver(exc)

def run(self):
self.transport.listen()
2 changes: 1 addition & 1 deletion marconi/queues/storage/__init__.py
@@ -1,7 +1,7 @@
"""Marconi Storage Drivers"""

from marconi.queues.storage import base
from marconi.queues.storage import exceptions # NOQA
from marconi.queues.storage import errors # NOQA

# Hoist classes into package namespace
ControlDriverBase = base.ControlDriverBase
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions marconi/queues/storage/mongodb/catalogue.py
Expand Up @@ -24,7 +24,7 @@
"""

import marconi.openstack.common.log as logging
from marconi.queues.storage import base, exceptions
from marconi.queues.storage import base, errors
from marconi.queues.storage.mongodb import utils


Expand Down Expand Up @@ -67,7 +67,7 @@ def get(self, project, queue):
fields=fields)

if entry is None:
raise exceptions.QueueNotMapped(project, queue)
raise errors.QueueNotMapped(project, queue)

return _normalize(entry)

Expand All @@ -90,7 +90,7 @@ def update(self, project, queue, shard=None):
res = self._insert(project, queue, shard, upsert=False)

if not res['updatedExisting']:
raise exceptions.QueueNotMapped(project, queue)
raise errors.QueueNotMapped(project, queue)

@utils.raises_conn_error
def drop_all(self):
Expand Down
10 changes: 5 additions & 5 deletions marconi/queues/storage/mongodb/claims.py
Expand Up @@ -28,7 +28,7 @@
import marconi.openstack.common.log as logging
from marconi.openstack.common import timeutils
from marconi.queues import storage
from marconi.queues.storage import exceptions
from marconi.queues.storage import errors
from marconi.queues.storage.mongodb import utils


Expand Down Expand Up @@ -64,7 +64,7 @@ def get(self, queue, claim_id, project=None):
now = timeutils.utcnow_ts()
cid = utils.to_oid(claim_id)
if cid is None:
raise exceptions.ClaimDoesNotExist(queue, project, claim_id)
raise errors.ClaimDoesNotExist(queue, project, claim_id)

def messages(msg_iter):
msg = next(msg_iter)
Expand Down Expand Up @@ -93,7 +93,7 @@ def messages(msg_iter):
'id': str(claim['id']),
}
except StopIteration:
raise exceptions.ClaimDoesNotExist(cid, queue, project)
raise errors.ClaimDoesNotExist(cid, queue, project)

return (claim_meta, msgs)

Expand Down Expand Up @@ -195,7 +195,7 @@ def create(self, queue, metadata, project=None, limit=None):
def update(self, queue, claim_id, metadata, project=None):
cid = utils.to_oid(claim_id)
if cid is None:
raise exceptions.ClaimDoesNotExist(claim_id, queue, project)
raise errors.ClaimDoesNotExist(claim_id, queue, project)

now = timeutils.utcnow_ts()
ttl = int(metadata.get('ttl', 60))
Expand All @@ -208,7 +208,7 @@ def update(self, queue, claim_id, metadata, project=None):
try:
next(claimed)
except StopIteration:
raise exceptions.ClaimDoesNotExist(claim_id, queue, project)
raise errors.ClaimDoesNotExist(claim_id, queue, project)

meta = {
'id': cid,
Expand Down

0 comments on commit 5624bf1

Please sign in to comment.