Closed wanda2003 closed 3 years ago
Currently, the exception raised when a 404 is received is:
beckett.exceptions.InvalidStatusCodeError: Received status code: 404, expected: (200, 201, 204)
You could do:
except beckett.exceptions.InvalidStatusCodeError as e:
if e.status_code = 404:
...
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 triedrequests.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
: