Skip to content

Commit 9fda038

Browse files
authored
Add unsupported host exception (#339)
1 parent 0071101 commit 9fda038

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

sagemcom_api/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
UnauthorizedException,
5252
UnknownException,
5353
UnknownPathException,
54+
UnsupportedHostException,
5455
)
5556
from .models import Device, DeviceInfo, PortMapping
5657

@@ -203,6 +204,10 @@ async def __post(self, url, data):
203204
result = await response.text()
204205
raise BadRequestException(result)
205206

207+
if response.status == 404:
208+
result = await response.text()
209+
raise UnsupportedHostException(result)
210+
206211
if response.status != 200:
207212
result = await response.text()
208213
raise UnknownException(result)

sagemcom_api/exceptions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ class UnknownException(BaseSagemcomException):
1818
"""Unknown exception."""
1919

2020

21+
class UnsupportedHostException(BaseSagemcomException):
22+
"""Raised when API is not available on given host."""
23+
24+
2125
# Exceptions provided by SagemCom API
2226
class AccessRestrictionException(BaseSagemcomException):
2327
"""Raised when current user has access restrictions."""

0 commit comments

Comments
 (0)