Open
Conversation
ron-at-swgy
commented
Dec 8, 2025
| handle_response(response, decoder, endpoint, params) | ||
| end | ||
|
|
||
| def execute_request(endpoint, params) |
Contributor
Author
There was a problem hiding this comment.
Extracted to satisfy Rubocop
There was a problem hiding this comment.
Pull request overview
This pull request enhances error reporting in the SerpApi Ruby client by enriching the SerpApiError exception class with contextual attributes (API error message, search parameters, HTTP status, search ID, and decoder type) and refactoring the error handling logic in the client for better maintainability.
- Enhanced
SerpApiErrorclass with five new optional attributes for detailed error context - Refactored client error handling into focused helper methods with centralized error raising
- Updated version to 1.0.3 and adjusted RuboCop configuration to accommodate the changes
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/serpapi/error.rb | Added new error attributes with validation methods and a to_h serialization method |
| lib/serpapi/client.rb | Refactored error handling into separate methods (execute_request, handle_response, process_json_response, process_html_response, raise_http_error, raise_parser_error) and updated all error raising to include new context attributes |
| spec/serpapi/client/client_spec.rb | Updated test expectations to match new error message format |
| lib/serpapi/version.rb | Bumped version from 1.0.2 to 1.0.3 |
| README.md.erb | Updated gem version reference to 1.0.3 |
| README.md | Updated gem version reference to 1.0.3 |
| .rubocop.yml | Relaxed Metrics/ClassLength and Metrics/ParameterLists constraints to accommodate the enhanced error class |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request enhances the
SerpApi::SerpApiErrorclass to include additional details:serpapi_error- The contents of theerrorattribute of the parsed JSON response object, if availablesearch_params- The original query params used for the searchresponse_status- HTTP response statussearch_id- The search id, from the search metadata, from the parsed JSON response object, if availabledecoder- The decoded used in the request (jsonorhtml)With this additional information, client code can print out the search ID for failed searches with something like:
This pull request fixes #15