diff --git a/docs/changelog.rst b/docs/changelog.rst index 90bc9199..c300f8ba 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -13,6 +13,8 @@ v3.3.0 Bug Fixes ~~~~~~~~~ - Fixed an issue that caused a :class:`KeyError` to be raised when using :meth:`fortnite_api.Client.search_br_cosmetics` or :meth:`fortnite_api.SyncClient.search_br_cosmetics` without `multiple` parameter. +- Fixed an issue that caused :class:`fortnite_api.Asset.resize` to raise :class:`TypeError` instead of :class:`ValueError` when the given size isn't a power of 2. +- Fixed an issue that caused :class:`fortnite_api.ServiceUnavailable` to be raised with a static message as a fallback for all unhandled http status codes. Instead :class:`fortnite_api.HTTPException` is raised with the proper error message. .. _vp3p2p0: diff --git a/fortnite_api/asset.py b/fortnite_api/asset.py index 60baf2fa..df99ce50 100644 --- a/fortnite_api/asset.py +++ b/fortnite_api/asset.py @@ -146,7 +146,7 @@ def resize(self, size: int) -> Self: raise ValueError('This asset does not support resizing.') if (size & (size - 1) != 0) or size <= 0: - raise TypeError('Size must be a power of 2.') + raise ValueError('Size must be a power of 2.') if self._max_size is not None: if size > self._max_size: diff --git a/fortnite_api/http.py b/fortnite_api/http.py index 551e4b67..4147cc7b 100644 --- a/fortnite_api/http.py +++ b/fortnite_api/http.py @@ -426,19 +426,18 @@ async def request(self, route: Route, **kwargs: Any) -> Any: continue - if response.status in {500, 502, 504}: + if response.status > 500: await asyncio.sleep(1 + tries * 2) continue - if response.status > 500: - raise ServiceUnavailable(error, response, data) - if response is not None: # If we hit the limit 5 times, there are bigger issues. if response.status == 429: raise RateLimited(error, response, data) + if response.status > 500: + raise ServiceUnavailable(error, response, data) - raise ServiceUnavailable('Service unavailable', response, data) + raise HTTPException(error, response, data) raise RuntimeError('Unreachable code reached!') @@ -518,17 +517,17 @@ def request(self, route: Route, **kwargs: Any) -> Any: continue - if response.status_code in {500, 502, 504}: + if response.status_code > 500: time.sleep(1 + tries * 2) continue - if response.status_code > 500: - raise ServiceUnavailable(error, response, data) - if response is not None: + # If we hit the limit 5 times, there are bigger issues. if response.status_code == 429: raise RateLimited(error, response, data) + if response.status_code > 500: + raise ServiceUnavailable(error, response, data) - raise ServiceUnavailable('Service unavailable', response, data) + raise HTTPException(error, response, data) raise RuntimeError('Unreachable code reached!')