Skip to content

Conversation

@tanys123
Copy link

@tanys123 tanys123 commented Dec 2, 2025

Related #17

The status code is essential to determine the issue with the API, which we documented in Status and Error Codes. This PR add the info to the serpapi.HTTPError exception.

@tanys123 tanys123 requested review from Copilot and jvmvik December 2, 2025 02:47
Copilot finished reviewing on behalf of tanys123 December 2, 2025 02:50
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the serpapi.HTTPError exception class to expose essential diagnostic information—specifically the HTTP status code and error message—making it easier for API consumers to handle different error scenarios according to SerpApi's documented Status and Error Codes.

Key Changes:

  • Added status_code and error properties to HTTPError by implementing a custom __init__ method
  • Added unit tests to verify the new exception attributes work correctly
  • Updated integration tests to validate the new properties in real-world scenarios

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
serpapi/exceptions.py Implements custom __init__ for HTTPError to extract and store status_code and error from the HTTP response
tests/test_exceptions.py Adds new unit test file with test coverage for the enhanced HTTPError exception properties
tests/test_integration.py Updates existing integration tests to validate both status_code and error attributes in real API failure scenarios

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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