Skip to content

Handle exceeding the limit gracefully #2067

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pygeoapi/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1670,7 +1670,7 @@ def evaluate_limit(requested: Union[None, int], server_limits: dict,
if requested2 <= 0:
raise ValueError('limit value should be strictly positive')
elif requested2 > max_ and on_exceed == 'error':
raise RuntimeError('Limit exceeded; throwing errror')
raise ValueError(f'Limit of {max_} exceeded')
else:
LOGGER.debug('limit requested')
return min(requested2, max_)
2 changes: 1 addition & 1 deletion tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ def test_evaluate_limit():
collection = {}
server = {'default_items': 2, 'max_items': 3, 'on_exceed': 'error'}

with pytest.raises(RuntimeError):
with pytest.raises(ValueError):
assert evaluate_limit('40', server, collection) == 40

collection = {'default_items': 10}
Expand Down