Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: catch&raise stray response HTTP status codes #227

Merged
merged 2 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion coc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
SOFTWARE.
"""

__version__ = "3.3.0"
__version__ = "3.3.1"

from .abc import BasePlayer, BaseClan
from .clans import RankedClan, Clan
Expand Down
4 changes: 3 additions & 1 deletion coc/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,16 @@ async def request(self, route, **kwargs):
await asyncio.sleep(tries * 2 + 1)
continue

# catch any stray status codes
raise HTTPException(response, data)

except asyncio.TimeoutError:
# api timed out, retry again
if tries > 3:
raise GatewayError("The API timed out waiting for the request.")

await asyncio.sleep(tries * 2 + 1)
continue
raise

else:
if response.status in (500, 502, 504):
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
project = 'coc'
copyright = '2022, mathsman5133'
author = 'mathsman5133'
release = '3.3.0'
release = '3.3.1'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
8 changes: 8 additions & 0 deletions docs/miscellaneous/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ Changelog
This page keeps a fairly detailed, human readable version
of what has changed, and whats new for each version of the lib.

v3.3.1
------

Bugs Fixed:
~~~~~~~~~~~
- Fixed a behaviour where in some cases (when the API responds with an unusual status code), coc.py would not
properly raise an :class:`HTTPException`

v3.3.0
------

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "coc.py"
authors = [{ name = "mathsman5133" }]
maintainers = [{ name = "majordoobie" }, { name = "MagicTheDev" }, { name = "Kuchenmampfer" },
{ name = "lukasthaler"}, { name = "doluk"}]
version = "3.3.0"
version = "3.3.1"
description = "A python wrapper for the Clash of Clans API"
requires-python = ">=3.7.3"
readme = "README.rst"
Expand Down
Loading