Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

twitterApi will return exception which are not twitter exceptions #240

Open
GoogleCodeExporter opened this issue Aug 6, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

Hi,

I run into the following problem. 
The twitter api says it will raise an twitter.exception if something goes 
wrong. Unfortunately also BadStatusLine-Exceptions will be raised as httplib 
will raise it and python-twitter will no handle it.
Here is a log from something like that occurring.

2012-09-26 23:45:04,505 [ERROR   ] 
Traceback (most recent call last):
  File "/harryplotter/harryplotter.py", line 69, in <module>
    tweets = get_tweets_by_terms(terms, last_id, tweets_per_page = config.getint("twitter", "tweets_per_page"), recursive = True)
  File "/harryplotter/harrytools.py", line 9, in get_tweets_by_terms
    tweets = get_tweets_by_term(term, last_id, refresh_time, tweets_per_page, recursive)
  File "/harryplotter/harrytools.py", line 24, in get_tweets_by_term
    tweets = twitter.Api().GetSearch(term=term, since_id=last_id, per_page=tweets_per_page, lang=None)
  File "/usr/local/lib/python2.6/dist-packages/python_twitter-0.8.2-py2.6.egg/twitter.py", line 2396, in GetSearch
    json = self._FetchUrl(url, parameters=parameters)
  File "/usr/local/lib/python2.6/dist-packages/python_twitter-0.8.2-py2.6.egg/twitter.py", line 3794, in _FetchUrl
    response = opener.open(url, encoded_post_data)
  File "/usr/lib/python2.6/urllib2.py", line 391, in open
    response = self._open(req, data)
  File "/usr/lib/python2.6/urllib2.py", line 409, in _open
    '_open', req)
  File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.6/urllib2.py", line 1170, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib/python2.6/urllib2.py", line 1143, in do_open
    r = h.getresponse()
  File "/usr/lib/python2.6/httplib.py", line 990, in getresponse
    response.begin()
  File "/usr/lib/python2.6/httplib.py", line 391, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python2.6/httplib.py", line 355, in _read_status
    raise BadStatusLine(line)
BadStatusLine

If this is expected behaviour, please document these or, as I prefer, catch it 
and return your own documented exception.

With best regards

pininety


Original issue reported on code.google.com by [email protected] on 27 Sep 2012 at 3:34

@GoogleCodeExporter
Copy link
Author

Hi,
this is my first patch, so please be kind if I do something wrong.
I used the latest dev (tip was 189).
With best regards

pininety

Original comment by [email protected] on 9 Oct 2012 at 10:44

Attachments:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant