I’m seeing inconsistent error codes returned when querying non-existent screen_names.
For some screen_names, calls to
statuses/user_timeline, _
users/lookup and
users/show
all return an (expected) 404. (NOT FOUND)
For others , calls to
users/lookup and
users/show
both return the expected 404, but calls to
statuses/user_timeline returns 401 (UNAUTHORISED)
Trapping errors in order to trigger useful and accurate actions in response requires consistency, so this is problematic.
FWIW it does seem that the screen_names that trigger a 401 are accounts that have been registered but subsequently been deleted, while a screen_name for an account that has never been registered consistently triggers a 404.
Python 2.7//Twython//Linux.
EDIT:
It actually seems even more complicated than this.
Sometimes on two consecutive calls with the same API call I can get two different responses: 401/Unauthorised and 401/Error processing your request.
Plus it’s not just non-existent accounts that offer up problems. Suspended accounts give 401, 403 or 404 depending which call is used.
Locked/blocked/blocking accounts seem to give either 401 or 200.
What I don’t know is whether Twython’s error handling is being misleading, or whether Twitter’s error codes are inconsistent, or perhaps it’s 6 of one and 1/2 dozen of the other?