Fix error msg in sort_items

Include direction users pass in the error msg to help users know
which part of the argument is troublesome.

Change-Id: I796a85fbf40f6ddf544fb52a61f967e1914abdcc
Closes-Bug: #1420732
This commit is contained in:
zhiyuan_cai 2015-02-11 10:35:10 +08:00
parent 9400effd4b
commit d13023b32a

@ -200,8 +200,14 @@ def sort_items(items, sort_str):
reverse = False
if ':' in sort_key:
sort_key, direction = sort_key.split(':', 1)
if not sort_key:
msg = "empty string is not a valid sort key"
raise exceptions.CommandError(msg)
if direction not in ['asc', 'desc']:
msg = "Specify sort direction by asc or desc"
if not direction:
direction = "empty string"
msg = ("%s is not a valid sort direction for sort key %s, "
"use asc or desc instead" % (direction, sort_key))
raise exceptions.CommandError(msg)
if direction == 'desc':
reverse = True