summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--oslo_db/exception.py5
-rw-r--r--oslo_db/sqlalchemy/utils.py2
-rw-r--r--oslo_db/tests/sqlalchemy/test_utils.py4
3 files changed, 6 insertions, 5 deletions
diff --git a/oslo_db/exception.py b/oslo_db/exception.py
index ffa0931..cca061c 100644
--- a/oslo_db/exception.py
+++ b/oslo_db/exception.py
@@ -183,9 +183,10 @@ class DBDataError(DBError):
class InvalidSortKey(Exception):
"""A sort key destined for database query usage is invalid."""
- def __init__(self):
+ def __init__(self, key):
super(InvalidSortKey, self).__init__(
- _("Sort key supplied was not valid."))
+ _("Sort key supplied is invalid: %s") % key)
+ self.key = key
class ColumnError(Exception):
diff --git a/oslo_db/sqlalchemy/utils.py b/oslo_db/sqlalchemy/utils.py
index 4f6a072..92b443a 100644
--- a/oslo_db/sqlalchemy/utils.py
+++ b/oslo_db/sqlalchemy/utils.py
@@ -123,7 +123,7 @@ def paginate_query(query, model, limit, sort_keys, marker=None,
try:
inspect(model).all_orm_descriptors[current_sort_key]
except KeyError:
- raise exception.InvalidSortKey()
+ raise exception.InvalidSortKey(current_sort_key)
else:
sort_key_attr = getattr(model, current_sort_key)
diff --git a/oslo_db/tests/sqlalchemy/test_utils.py b/oslo_db/tests/sqlalchemy/test_utils.py
index 2abda34..6d48814 100644
--- a/oslo_db/tests/sqlalchemy/test_utils.py
+++ b/oslo_db/tests/sqlalchemy/test_utils.py
@@ -149,8 +149,8 @@ class TestPaginateQuery(test_base.BaseTestCase):
sort_dirs=['asc', 'desc'])
def test_invalid_sort_key_str(self):
- self.assertEqual("Sort key supplied was not valid.",
- str(exception.InvalidSortKey()))
+ self.assertEqual("Sort key supplied is invalid: lol",
+ str(exception.InvalidSortKey("lol")))
def test_paginate_query_attribute_error(self):
sqlalchemy.asc(self.model.user_id).AndReturn('asc')