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

fix: raise exception on status code gt 400 #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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