Skip to content

Commit 9ce112f

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Fix error msg in sort_items"
2 parents b972937 + d13023b commit 9ce112f

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎openstackclient/common/utils.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,14 @@ def sort_items(items, sort_str):
200200
reverse = False
201201
if ':' in sort_key:
202202
sort_key, direction = sort_key.split(':', 1)
203+
if not sort_key:
204+
msg = "empty string is not a valid sort key"
205+
raise exceptions.CommandError(msg)
203206
if direction not in ['asc', 'desc']:
204-
msg = "Specify sort direction by asc or desc"
207+
if not direction:
208+
direction = "empty string"
209+
msg = ("%s is not a valid sort direction for sort key %s, "
210+
"use asc or desc instead" % (direction, sort_key))
205211
raise exceptions.CommandError(msg)
206212
if direction == 'desc':
207213
reverse = True

0 commit comments

Comments
 (0)