From 60b5b14988b2986c161e6a25dc5030a31d41728b Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 13 Jun 2016 18:56:17 -0400 Subject: Memoize sys.exc_info() before attempting a savepoint rollback This presents a system of reporting the ultimate "cause" in the case that a MySQL failed SAVEPOINT rollback occurs. Change-Id: Iea834429a0b8398f076b10426525a5c17dbf3c85 --- oslo_db/exception.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'oslo_db/exception.py') diff --git a/oslo_db/exception.py b/oslo_db/exception.py index 16dec7f..2d118cd 100644 --- a/oslo_db/exception.py +++ b/oslo_db/exception.py @@ -47,9 +47,10 @@ import debtcollector.removals import six from oslo_db._i18n import _ +from oslo_utils.excutils import CausedByException -class DBError(Exception): +class DBError(CausedByException): """Base exception for all custom database exceptions. @@ -57,9 +58,9 @@ class DBError(Exception): DBError or its subclasses. """ - def __init__(self, inner_exception=None): + def __init__(self, inner_exception=None, cause=None): self.inner_exception = inner_exception - super(DBError, self).__init__(six.text_type(inner_exception)) + super(DBError, self).__init__(six.text_type(inner_exception), cause) class DBDuplicateEntry(DBError): -- cgit v1.2.1