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

84 - HTTP Error code handling 400+ #87

Merged
merged 5 commits into from
Nov 23, 2024
Merged

84 - HTTP Error code handling 400+ #87

merged 5 commits into from
Nov 23, 2024

Conversation

coreyjs
Copy link
Owner

@coreyjs coreyjs commented Nov 22, 2024

feat: Enhance HTTP client error handling with custom exceptions

  • Implement hierarchical exception system with base NHLApiException
  • Add specific exceptions for common HTTP status codes (404, 429, 400, 401, 5xx)
  • Create centralized error handling in _handle_response method
  • Add comprehensive test suite with pytest for all error scenarios
  • Improve error message formatting to include both request context and API response
  • Handle edge cases for malformed JSON and non-JSON responses
  • Add type checking for response parsing
  • Fixes double encoding bug in stats.team_summary() for notebooks.

Tests cover:

  • All HTTP error status codes
  • Success responses
  • Non-JSON responses
  • Malformed JSON handling
  • Query parameter handling
  • Verbose logging behavior

Breaking changes: None - extends existing error handling functionality

- Implement hierarchical exception system with base NHLApiException
- Add specific exceptions for common HTTP status codes (404, 429, 400, 401, 5xx)
- Create centralized error handling in _handle_response method
- Add comprehensive test suite with pytest for all error scenarios
- Improve error message formatting to include both request context and API response
- Handle edge cases for malformed JSON and non-JSON responses
- Add type checking for response parsing

Tests cover:
- All HTTP error status codes
- Success responses
- Non-JSON responses
- Malformed JSON handling
- Query parameter handling
- Verbose logging behavior

Breaking changes: None - extends existing error handling functionality
Closes #81
@coreyjs coreyjs self-assigned this Nov 22, 2024
@coreyjs coreyjs linked an issue Nov 22, 2024 that may be closed by this pull request
@coreyjs
Copy link
Owner Author

coreyjs commented Nov 22, 2024

This is gonna get a minor bump due to touching code that affects every request. Im gonna test this via ! pip install -i https://test.pypi.org/simple/ nhl-api-py -U in a bit

@coreyjs coreyjs merged commit 9ebb230 into main Nov 23, 2024
1 check passed
@coreyjs coreyjs deleted the 84 branch November 23, 2024 14:51
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.

404 error for Edmonton 1990-1991
1 participant