You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, first of all, it works great. But I'm curious: what would be the best way to handle 404 error when using .get_pokemon?
I have tried requests.get("https://pokeapi.co/api/v2/pokemon") and do except requests.HTTPError but it seems that it's not a solution. The only way it could work is to use nested try-except but I don't think that's a good approach.
I also try to look in the documentation but can't seems to find one address this.
Currently, the exception raised when a 404 is received is: beckett.exceptions.InvalidStatusCodeError: Received status code: 404, expected: (200, 201, 204)
Hi, first of all, it works great. But I'm curious: what would be the best way to handle 404 error when using
.get_pokemon
?I have tried
requests.get("https://pokeapi.co/api/v2/pokemon")
and doexcept requests.HTTPError
but it seems that it's not a solution. The only way it could work is to use nestedtry-except
but I don't think that's a good approach.I also try to look in the documentation but can't seems to find one address this.
Thank you for any suggestions.
Illustrate what I mean by nested
try-except
:The text was updated successfully, but these errors were encountered: