Skip to content

Commit

Permalink
Add unsupported host exception (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
iMicknl authored Aug 9, 2024
1 parent 0071101 commit 9fda038
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sagemcom_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
UnauthorizedException,
UnknownException,
UnknownPathException,
UnsupportedHostException,
)
from .models import Device, DeviceInfo, PortMapping

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions sagemcom_api/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down

0 comments on commit 9fda038

Please sign in to comment.