Skip to content

Error handling improvements#154

Merged
wkdewey merged 4 commits into
devfrom
error-handling
Jul 14, 2026
Merged

Error handling improvements#154
wkdewey merged 4 commits into
devfrom
error-handling

Conversation

@techgique

Copy link
Copy Markdown
Member

No description provided.

techgique added 3 commits July 2, 2026 15:54
- Return raw `res` from `post` method so we can interact with it
  appropriately depending on the response from the search service
- DRY up code in different search methods
- Make default friendly error message less generic, indicating the
  search service encountered an error
- Handle different errors returned from search service
  - RuntimeError - Failed to communicate with search service
  - Forbidden - 40x response indicating access denied, indicating IP or
    user/pass auth configuration requires attention
  - BadRequest - Malformed request or search service syntax error,
    including if the query includes a mix of smart and regular quotes
  - ExceptionWithResponse - Catch all for all other errors
- Move post to protected methods
- Alphabetize protected methods
@techgique

Copy link
Copy Markdown
Member Author

Query string that will cause Elasticsearch to choke on a syntax error:
“I have studied many philosophers and many cats. The wisdom of cats is infinitely superior.”"

@wkdewey wkdewey left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good. Tested with TEAA.

Comment thread app/services/search_service.rb Outdated
res = post("_search", req)
if res.class == RuntimeError
on_error(res.inspect, req,
"There was an error communicating with to the search service")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete extraneous "to"

@wkdewey wkdewey merged commit 210a780 into dev Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants