diff options
| author | Todd Willey <todd@ansolabs.com> | 2011-01-25 17:51:49 -0800 |
|---|---|---|
| committer | Todd Willey <todd@ansolabs.com> | 2011-01-25 17:51:49 -0800 |
| commit | be28eceff7b0a7a1dc33c3ade3ab221c6b1c8acd (patch) | |
| tree | d0d71f4baae6f8da19e8e5389144d45123df5a66 /nova/exception.py | |
| parent | bbea3a093f3e9be5052a2e64b6d5d0b909ae33ee (diff) | |
| parent | 5e4259ce6deb227b778acf23770e35f786c9c3d0 (diff) | |
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: |
