statsbomb / statsbombpy

Easily stream StatsBomb data into Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Raise appropriate error when resource does not exist

probberechts opened this issue · comments

When trying to retrieve a resource which does not exist, statsbombpy throws a JSONDecodeError. Example:

>> from statsbombpy import sb
>> sb.events(1234)
JSONDecodeError: Extra data: line 1 column 4 (char 3)

To help users understand what went wrong, it would be more appropriate to throw a ResourceNotFoundError (or something alike).

We decided to add status checks to the public API calls so that the correct HTTP error is returned when the user tries to access a resource that does not exist.

For more details: https://github.com/statsbomb/statsbombpy/releases/tag/v.1.10.1

Hope that helps.