Skip to content
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

Handle ProviderInvalidQueryError for every query() #1379

Merged
Merged
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
17 changes: 17 additions & 0 deletions pygeoapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1653,6 +1653,12 @@ def get_collection_items(
select_properties=select_properties,
crs_transform_spec=crs_transform_spec,
q=q, language=prv_locale, filterq=filter_)
except ProviderInvalidQueryError as err:
LOGGER.error(err)
msg = f'query error: {err}'
return self.get_exception(
HTTPStatus.BAD_REQUEST, headers, request.format,
'InvalidQuery', msg)
except ProviderConnectionError as err:
LOGGER.error(err)
msg = 'connection error (check logs)'
Expand Down Expand Up @@ -2074,6 +2080,12 @@ def post_collection_items(
skip_geometry=skip_geometry,
q=q,
filterq=filter_)
except ProviderInvalidQueryError as err:
LOGGER.error(err)
msg = f'query error: {err}'
return self.get_exception(
HTTPStatus.BAD_REQUEST, headers, request.format,
'InvalidQuery', msg)
except ProviderConnectionError as err:
LOGGER.error(err)
msg = 'connection error (check logs)'
Expand Down Expand Up @@ -3853,6 +3865,11 @@ def get_collection_edr_query(

try:
data = p.query(**query_args)
except ProviderInvalidQueryError as err:
msg = f'query error: {err}'
return self.get_exception(
HTTPStatus.BAD_REQUEST, headers, request.format,
'InvalidQuery', msg)
except ProviderNoDataError:
msg = 'No data found'
return self.get_exception(
Expand Down
Loading