exc_filters: Do not reraise

We're seeing a weird condition whereby the exceptions raised by our
exception handler and being "rehandled", resulting in 'DBError' being
raised instead of e.g. 'DBReferenceError'. This is hard to reproduce and
thus far has only be spotted in Barbican unit tests. Prevent the issue
by checking if the exception being handled is one of our own and skip
handling it if so.

Change-Id: Ibd3f665a3ed3aedf9d1f33edcab35a46c27ea3dc
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2023-07-14 15:39:47 +01:00
parent 6285f2b4e2
commit 8dcd47383d

View File

@ -430,6 +430,10 @@ def handler(context):
if '*' in _registry:
yield _registry['*']
# do not reraise for our own exceptions
if isinstance(context.original_exception, exception.DBError):
return
dialect = compat.dialect_from_exception_context(context)
for per_dialect in _dialect_registries(dialect):
for exc in (context.sqlalchemy_exception, context.original_exception):