Skip to content

Add typed Pi-hole v6 errors#37

Merged
fabaff merged 1 commit into
home-assistant-ecosystem:masterfrom
headdirt:typed-v6-errors
Jun 5, 2026
Merged

Add typed Pi-hole v6 errors#37
fabaff merged 1 commit into
home-assistant-ecosystem:masterfrom
headdirt:typed-v6-errors

Conversation

@headdirt

@headdirt headdirt commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Add typed exceptions for v6 API error handling so callers can react to why a specific request has failed.

Changes

  • New exception types (subclasses of HoleError):
    • HoleAuthenticationError - authentication required, missing, or invalid (HTTP 401)
    • HoleResponseError - unexpected or unparseable payload
  • HoleError now carries optional status with the HTTP status code
  • _fetch_data raises HoleAuthenticationError when a request is still 401 after the re-auth retry, and HoleResponseError when the body can't be parsed as JSON (existing session-expiry re-auth behavior is unchanged)
  • authenticate raises HoleAuthenticationError on a 401, and HoleResponseError on an unparseable body
  • Behavioral change: get_versions validates /info/versions and raises HoleResponseError instead of leaving versions empty
  • Added tests

@fabaff fabaff left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me.

Thanks

@fabaff fabaff merged commit a922e2a into home-assistant-ecosystem:master Jun 5, 2026
2 checks passed
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