Skip to content
This repository was archived by the owner on Sep 15, 2023. It is now read-only.

fix: raise exception on status code gt 400#22

Open
g-rar wants to merge 1 commit intoblha303:masterfrom
g-rar:g-rar/fix/raise-exception-other-than-404
Open

fix: raise exception on status code gt 400#22
g-rar wants to merge 1 commit intoblha303:masterfrom
g-rar:g-rar/fix/raise-exception-other-than-404

Conversation

@g-rar
Copy link

@g-rar g-rar commented Nov 10, 2022

As mentioned on this issue, the package does not raise exceptions on status code 420. Furthermore, I was experiencing issues while tryin to execute the following code:

mc = sr_api.search(srcomapi.datatypes.Game, {"name": "Minecraft: Java Edition"})[0]
cat = mc.categories[0].records[0].category
board = sdt.Leaderboard(sr_api, data = sr_api.get(f"leaderboards/{mc.id}/category/{cat.id}?embed=players"))
print(len(board.runs))

Result was a JSONDecodeError, which was being thrown because underlying request was receiving status code 408, and code was setup to throw exception only on status_code 404.

With this oneliner, it'd throw exception on status_code > 404

@g-rar g-rar marked this pull request as ready for review November 10, 2022 02:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant