gfcapalbo / python-twitter

Automatically exported from code.google.com/p/python-twitter
Apache License 2.0
0 stars 0 forks source link

python-twitter should catch 401 errors #33

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Call _FetchUrl with a good username and a bad password, and it fails out
with urllib2 raising a HTTPError.  python-twitter should probably catch that.

What is the expected output? What do you see instead?
I expect python-twitter to fial gracefully, and it kinda doesn't.

What version of the product are you using? On what operating system?
Version 0.5
Debian Lenny

Original issue reported on code.google.com by ay1244 on 20 Nov 2008 at 5:59

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
In the bug report, by python-twitter, I mean the tweet program included with 
it. 
Sorry for the confusion.

Original comment by ay1244 on 22 Nov 2008 at 3:53

GoogleCodeExporter commented 9 years ago
I could go either way here.  We could either wrap the HTTPError exceptions with 
a
TwitterError, or we could pass them through.  I feel like it is probably more
informative to the caller to get the HTTPError, but I don't feel strongly 
either way.

Original comment by dclinton on 21 Feb 2009 at 5:33

GoogleCodeExporter commented 9 years ago
fwiw I would rather have the httperror

Original comment by errr.errr on 21 Feb 2009 at 6:29

GoogleCodeExporter commented 9 years ago
The same issue happens with 403 errors. Twitter is returning error messages 
when you
get these 401 and 403 errors. It should be handled gracefully. Otherwise you are
expecting the consumer of the library to know that 401 and 403 should be caught 
and
also that the contents of the returned page have informative error messages.

Now, if the twitter error message is NOT included in the 401 and 403, then 
throw the
HTTPError instead of the TwitterError

Original comment by djensen47 on 23 Mar 2009 at 12:45

GoogleCodeExporter commented 9 years ago
I could pretty easily write the code to catch and wrap the 401 & 403 errors, 
but I'm
waiting on three other patches to be committed at the moment, so I'll hold off 
until
those are dealt with.  I don't want the backlog to grow too big.

Original comment by cydeweys on 23 Mar 2009 at 1:38

GoogleCodeExporter commented 9 years ago
The httperror is fine now that oauth authentication is used. Anyway, as a 
newbie, it would have been nice if the documentation told me how to trap it.
try:
    api.GetSomething()
except twitter.TwitterError as err:
    print('%s: %s' % (a,err))

Original comment by themany...@gmail.com on 17 Oct 2010 at 9:45