I usually see HTTP status codes being checked as integer numbers:
if ((status >= 200) && (status < 300)) // or `<= 299`
This is rather verbose. But if you think about it, it's the first digit in the number that has a special value, and there are only five of them:
When treated as strings, checking for the error class looks a bit better:
if (status == '2')
Unfortunately, the ensuing party is pre-pooped by most client HTTP libraries helpfully casting the status to
Dear HTTP client libraries! Consider adding
response.error_class to your responses.