refactor: another refactor
Some checks failed
Integration Testing / Integration Tests (2024.12.0, 3.11) (push) Failing after 27s
Integration Testing / Integration Tests (2024.12.0, 3.12) (push) Failing after 56s
Integration Testing / Integration Tests (2024.12.0, 3.13) (push) Failing after 1m38s
Integration Testing / Integration Tests (2025.9.4, 3.11) (push) Failing after 19s
Integration Testing / Integration Tests (2025.9.4, 3.12) (push) Failing after 20s
Integration Testing / Integration Tests (2025.9.4, 3.13) (push) Failing after 25s
Code Quality Check / Code Quality Analysis (push) Failing after 20s
Code Quality Check / Security Analysis (push) Failing after 21s
Some checks failed
Integration Testing / Integration Tests (2024.12.0, 3.11) (push) Failing after 27s
Integration Testing / Integration Tests (2024.12.0, 3.12) (push) Failing after 56s
Integration Testing / Integration Tests (2024.12.0, 3.13) (push) Failing after 1m38s
Integration Testing / Integration Tests (2025.9.4, 3.11) (push) Failing after 19s
Integration Testing / Integration Tests (2025.9.4, 3.12) (push) Failing after 20s
Integration Testing / Integration Tests (2025.9.4, 3.13) (push) Failing after 25s
Code Quality Check / Code Quality Analysis (push) Failing after 20s
Code Quality Check / Security Analysis (push) Failing after 21s
Signed-off-by: Rafal Zielinski <sq4ind@gmail.com>
This commit is contained in:
@@ -13,22 +13,18 @@ _LOGGER = logging.getLogger(__name__)
|
||||
|
||||
class AdGuardHomeError(Exception):
|
||||
"""Base exception for AdGuard Home API."""
|
||||
pass
|
||||
|
||||
|
||||
class AdGuardConnectionError(AdGuardHomeError):
|
||||
"""Exception for connection errors."""
|
||||
pass
|
||||
|
||||
|
||||
class AdGuardAuthError(AdGuardHomeError):
|
||||
"""Exception for authentication errors."""
|
||||
pass
|
||||
|
||||
|
||||
class AdGuardNotFoundError(AdGuardHomeError):
|
||||
"""Exception for not found errors."""
|
||||
pass
|
||||
|
||||
|
||||
class AdGuardHomeAPI:
|
||||
@@ -43,7 +39,7 @@ class AdGuardHomeAPI:
|
||||
ssl: bool = False,
|
||||
session: Optional[aiohttp.ClientSession] = None,
|
||||
timeout: int = 10,
|
||||
):
|
||||
) -> None:
|
||||
"""Initialize the API wrapper."""
|
||||
self.host = host
|
||||
self.port = port
|
||||
@@ -107,11 +103,13 @@ class AdGuardHomeAPI:
|
||||
return {"response": text}
|
||||
|
||||
except asyncio.TimeoutError as err:
|
||||
raise AdGuardConnectionError(f"Timeout: {err}")
|
||||
raise AdGuardConnectionError(f"Timeout: {err}") from err
|
||||
except ClientError as err:
|
||||
raise AdGuardConnectionError(f"Client error: {err}")
|
||||
raise AdGuardConnectionError(f"Client error: {err}") from err
|
||||
except Exception as err:
|
||||
raise AdGuardHomeError(f"Unexpected error: {err}")
|
||||
if isinstance(err, AdGuardHomeError):
|
||||
raise
|
||||
raise AdGuardHomeError(f"Unexpected error: {err}") from err
|
||||
|
||||
async def test_connection(self) -> bool:
|
||||
"""Test the connection to AdGuard Home."""
|
||||
|
Reference in New Issue
Block a user