summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEndre Karlson <endre.karlson@hp.com>2015-08-10 15:10:42 +0200
committerKiall Mac Innes <kiall@hpe.com>2015-09-02 17:13:20 +0100
commit28087d860294986647922850ac07aa584d86c925 (patch)
treee17a571ba903da5e7bb57bf3730be0bf3556100d
parent9fa07c5798be54c2d99b270f6d3941235ee812f3 (diff)
downloaddesignate-28087d860294986647922850ac07aa584d86c925.tar.gz
Provide error messages on CRUD actions
Change-Id: I6b1adddd5cb53d82b34dbe153d9bec70be40c073
-rw-r--r--designate/sqlalchemy/base.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/designate/sqlalchemy/base.py b/designate/sqlalchemy/base.py
index cb127711..ab361ee4 100644
--- a/designate/sqlalchemy/base.py
+++ b/designate/sqlalchemy/base.py
@@ -182,7 +182,8 @@ class SQLAlchemy(object):
try:
resultproxy = self.session.execute(query, [dict(values)])
except oslo_db_exception.DBDuplicateEntry:
- raise exc_dup()
+ msg = "Duplicate %s" % obj.obj_name()
+ raise exc_dup(msg)
# Refetch the row, for generated columns etc
query = select([table]).where(
@@ -215,7 +216,8 @@ class SQLAlchemy(object):
results = resultproxy.fetchall()
if len(results) != 1:
- raise exc_notfound()
+ msg = "Could not find %s" % cls.obj_name()
+ raise exc_notfound(msg)
else:
return _set_object_from_model(cls(), results[0])
else:
@@ -284,10 +286,12 @@ class SQLAlchemy(object):
try:
resultproxy = self.session.execute(query)
except oslo_db_exception.DBDuplicateEntry:
- raise exc_dup()
+ msg = "Duplicate %s" % obj.obj_name()
+ raise exc_dup(msg)
if resultproxy.rowcount != 1:
- raise exc_notfound()
+ msg = "Could not find %s" % obj.obj_name()
+ raise exc_notfound(msg)
# Refetch the row, for generated columns etc
query = select([table]).where(table.c.id == obj.id)
@@ -321,7 +325,8 @@ class SQLAlchemy(object):
resultproxy = self.session.execute(query)
if resultproxy.rowcount != 1:
- raise exc_notfound()
+ msg = "Could not find %s" % obj.obj_name()
+ raise exc_notfound(msg)
# Refetch the row, for generated columns etc
query = select([table]).where(table.c.id == obj.id)