[DO NOT MERGE YET] Error handling and logging for global and policy searches #6581
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Related ticket: #6557
Try/Except
block handleConnection Errors
when the FEC API endpoints (Candidtes or Committees) or search.gov API are not responding. Also handleKey Error
,JSON Decode Error
or any other error that arises when the data retunred is not processable, search-result json.Required reviewers
One developer, One UX
Impacted areas of the application
General components of the application that this PR will affect:
Global site search
Policy Guidance search
modified: fec/static/scss/components/_messages.scss
modified: search/templates/search/policy_guidance_search_page.html
modified: search/templates/search/search.html
modified: search/views.py
Screenshot
If a search term returns no results, but there is also an error:
(If there is no error, it would show only the default no-result message, no need to list the types that were successfully searched)
Contingent on #6557
How to test
SEARCHGOV_API_ACCESS_KEY
andSEARCHGOV_POLICY_GUIDANCE_KEY
in terminal or add tobash_profile
orzsh profile
and source the profile in terminal.npm run build-sass
JSON Decode Error
by breaking the search.gov URL by changing a character in the URL inserach/views.py
line 113.Key Error
by exporting the wrong access key for search.gov, likeexport SEARCHGOV_API_ACCESS_KEY=1234
Connection Error
by changing the url on line 113 ofserach/views.py
to a site that does nor exist like: https://www.doesnotexist.com"tkts"
(screenshot above)