summaryrefslogtreecommitdiff
path: root/oslo_db/exception.py
diff options
context:
space:
mode:
authorJulien Danjou <julien@danjou.info>2015-04-03 16:29:00 +0200
committerJulien Danjou <julien@danjou.info>2015-04-03 16:29:00 +0200
commit124239cca7f52d037163de06f1a8b38dbaffc002 (patch)
tree22226dff07acb4d024b7a83690d46893a09012b1 /oslo_db/exception.py
parentf749ad436288841f9df5af284966b2b1c639e428 (diff)
downloadoslo-db-124239cca7f52d037163de06f1a8b38dbaffc002.tar.gz
Handle CHECK constraint integrity in PostgreSQL
PostgreSQL offers CHECK constraints integrity which are currently raised as generic error. This patch add a filter so they can have their own exception type. Change-Id: I7e36ef4385b227d1e62e18277d470047a369a238
Diffstat (limited to 'oslo_db/exception.py')
-rw-r--r--oslo_db/exception.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/oslo_db/exception.py b/oslo_db/exception.py
index f950f6a..3b9c3f9 100644
--- a/oslo_db/exception.py
+++ b/oslo_db/exception.py
@@ -87,6 +87,23 @@ class DBDuplicateEntry(DBError):
super(DBDuplicateEntry, self).__init__(inner_exception)
+class DBConstraintError(DBError):
+ """Check constraint fails for column error.
+
+ Raised when made an attempt to write to a column a value that does not
+ satisfy a CHECK constraint.
+
+ :kwarg table: the table name for which the check fails
+ :type table: str
+ :kwarg check_name: the table of the check that failed to be satisfied
+ :type check_name: str
+ """
+ def __init__(self, table, check_name, inner_exception=None):
+ self.table = table
+ self.check_name = check_name
+ super(DBConstraintError, self).__init__(inner_exception)
+
+
class DBReferenceError(DBError):
"""Foreign key violation error.