diff options
author | Roman Podoliaka <rpodolyaka@mirantis.com> | 2016-10-10 15:13:19 +0300 |
---|---|---|
committer | Roman Podoliaka <rpodolyaka@mirantis.com> | 2016-10-10 17:52:17 +0300 |
commit | 08d5f3bc029d07e78e1f38b822ad9a3ef21770ad (patch) | |
tree | de2b27f06c968958e4865375707b43b3418b8258 /oslo_db/exception.py | |
parent | 2f1944d24aea21066ac7b3bd9157c013c38166bc (diff) | |
download | oslo-db-08d5f3bc029d07e78e1f38b822ad9a3ef21770ad.tar.gz |
Add a specific exception for 'unknown database' errors
Add an exception filter to distinguish 'unknown database' errors from
other DBAPIError's. This effectively means we no longer
unconditionally print a traceback to logs, when someone tries to
connect to a database, that does not exist, but just raise a specific
exception instead and let the caller handle it.
Closes-Bug: #1631033
Change-Id: Iebc1ec1e8153917fbcde116d04bc171272993bbd
Diffstat (limited to 'oslo_db/exception.py')
-rw-r--r-- | oslo_db/exception.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/oslo_db/exception.py b/oslo_db/exception.py index 2d118cd..e66fe98 100644 --- a/oslo_db/exception.py +++ b/oslo_db/exception.py @@ -155,6 +155,18 @@ class DBNonExistentTable(DBError): super(DBNonExistentTable, self).__init__(inner_exception) +class DBNonExistentDatabase(DBError): + """Database does not exist. + + :param database: database name + :type database: str + """ + + def __init__(self, database, inner_exception=None): + self.database = database + super(DBNonExistentDatabase, self).__init__(inner_exception) + + class DBDeadlock(DBError): """Database dead lock error. |