diff options
| author | zhiyuan_cai <luckyvega.g@gmail.com> | 2015-02-11 10:35:10 +0800 |
|---|---|---|
| committer | zhiyuan_cai <luckyvega.g@gmail.com> | 2015-02-11 20:35:08 +0800 |
| commit | d13023b32a990241a4a0ebb7fb2dab5391c003e3 (patch) | |
| tree | 4c18962c9b3118b8026f5c764b44d44fcf8b809c /openstackclient/common/utils.py | |
| parent | 9400effd4b7653045657630e0909b3dc303ec59e (diff) | |
| download | python-openstackclient-d13023b32a990241a4a0ebb7fb2dab5391c003e3.tar.gz | |
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
Diffstat (limited to 'openstackclient/common/utils.py')
| -rw-r--r-- | openstackclient/common/utils.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/openstackclient/common/utils.py b/openstackclient/common/utils.py index 01a40e74..d1c7970a 100644 --- a/openstackclient/common/utils.py +++ b/openstackclient/common/utils.py @@ -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 |
