Closed allerter closed 3 years ago
@johnwmillr, this PR is ready to be merged. It's probably a good idea to resolve #158 and #159 too and then bump to 2.1.0 from 2.0.2
@johnwmillr, this PR is ready to be merged.
Thank you for resolving these merge conflicts. I need to study up on handling these conflicts and merge the PRs without screwing up the commit history!
I think LyricsGenius should raise HTTP and timeout errors since it's not the package's job to handle those errors. This would help with validating the token and informing the user of the result of their request. For example when the user requests something like
genius.get_annotation(0)
which is getting an item, the result of that request is a 404 error. On the other hand, if the user does a search likegenius.search_genius_web('sddjwi')
wich searches for an item, that request is valid and will have a 200 status code, but it won't have anything inside its sections. So I added raising HTTP and timeout errors. The timeout errors are raised throughrequests.exceptions.Timeout
, and all HTTPErrors will be raised throughrequestrs.exceptions.HTTPError
. Most of the time error descriptions is quite enough to figure out what's gone wrong. The user can also access the request's status code (two ways) and the error's description:I also added the
_validate_token()
method and calling when the Genius object instantiates (should it be called in the API object's instantiation?). The method only requests a song from Genius API which returns 401 with proper description if the token is invalid. This resolves #105I'd love to hear your thoughts on this.