diff options
author | Todd Willey <todd@ansolabs.com> | 2011-01-25 16:04:40 -0800 |
---|---|---|
committer | Todd Willey <todd@ansolabs.com> | 2011-01-25 16:04:40 -0800 |
commit | 0114eec76754c5759c438b47477b077f21196432 (patch) | |
tree | cdaa8770618ae88aaecaf138bd00c544457a17c2 /nova/exception.py | |
parent | 5fdf1132f3418c1f6ecaa5593835536db9895085 (diff) | |
parent | dbbaa7c41384c57b2aa10514518b71180316e64a (diff) | |
download | nova-0114eec76754c5759c438b47477b077f21196432.tar.gz nova-0114eec76754c5759c438b47477b077f21196432.tar.xz nova-0114eec76754c5759c438b47477b077f21196432.zip |
Merge trunk.
Diffstat (limited to 'nova/exception.py')
-rw-r--r-- | nova/exception.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/nova/exception.py b/nova/exception.py index 2320e2214..f604fd63a 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -81,6 +81,24 @@ class TimeoutException(Error): pass +class DBError(Error): + """Wraps an implementation specific exception""" + def __init__(self, inner_exception): + self.inner_exception = inner_exception + super(DBError, self).__init__(str(inner_exception)) + + +def wrap_db_error(f): + def _wrap(*args, **kwargs): + try: + return f(*args, **kwargs) + except Exception, e: + LOG.exception(_('DB exception wrapped')) + raise DBError(e) + return _wrap + _wrap.func_name = f.func_name + + def wrap_exception(f): def _wrap(*args, **kw): try: |