From 77a390b9a587123bfe4d97440fc1d41dba6ddb6a Mon Sep 17 00:00:00 2001 From: Mick Date: Fri, 9 Aug 2024 22:51:08 +0000 Subject: [PATCH] Add unsupported host exception --- sagemcom_api/client.py | 5 +++++ sagemcom_api/exceptions.py | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/sagemcom_api/client.py b/sagemcom_api/client.py index 39b7221..f5ee81a 100644 --- a/sagemcom_api/client.py +++ b/sagemcom_api/client.py @@ -51,6 +51,7 @@ UnauthorizedException, UnknownException, UnknownPathException, + UnsupportedHostException, ) from .models import Device, DeviceInfo, PortMapping @@ -203,6 +204,10 @@ async def __post(self, url, data): result = await response.text() raise BadRequestException(result) + if response.status == 404: + result = await response.text() + raise UnsupportedHostException(result) + if response.status != 200: result = await response.text() raise UnknownException(result) diff --git a/sagemcom_api/exceptions.py b/sagemcom_api/exceptions.py index 4fb2933..b547e34 100644 --- a/sagemcom_api/exceptions.py +++ b/sagemcom_api/exceptions.py @@ -18,6 +18,10 @@ class UnknownException(BaseSagemcomException): """Unknown exception.""" +class UnsupportedHostException(BaseSagemcomException): + """Raised when API is not available on given host.""" + + # Exceptions provided by SagemCom API class AccessRestrictionException(BaseSagemcomException): """Raised when current user has access restrictions."""