Fix exception msg

Missing 'limit' argument in api_common when giving exception msg

Change-Id: Ica648d10c4467e8c83cd3cdde3f1b51553900fcc
This commit is contained in:
hewei 2018-11-08 13:57:46 +08:00
parent 0f0f0a6287
commit 9b43ecec98
1 changed files with 4 additions and 3 deletions

View File

@ -84,7 +84,7 @@ def get_limit_and_marker(request):
pagination, then return None.
"""
max_limit = _get_pagination_max_limit()
limit = _get_limit_param(request, max_limit)
limit = _get_limit_param(request)
if max_limit > 0:
limit = min(max_limit, limit) or max_limit
if not limit:
@ -108,15 +108,16 @@ def _get_pagination_max_limit():
return max_limit
def _get_limit_param(request, max_limit):
def _get_limit_param(request):
"""Extract integer limit from request or fail."""
limit = -1
try:
limit = int(request.GET.get('limit', 0))
if limit >= 0:
return limit
except ValueError:
pass
msg = _("Limit must be an integer 0 or greater and not '%d'")
msg = _("Limit must be an integer 0 or greater and not '%d'") % limit
raise exceptions.BadRequest(resource='limit', msg=msg)