MeltwaterArchive / datasift-python

Python client to interface with DataSift
http://datasift.com/
MIT License
43 stars 28 forks source link

Better handling of permission errors #44

Closed paulmozo closed 9 years ago

paulmozo commented 10 years ago

If a user tries to access an endpoint they do not have access to the Python client throws an error along the lines of:

Traceback (most recent call last):
  File "historics.py", line 15, in <module>
    print(datasift.historics.status(start, end_time))
  File "/Library/Python/2.7/site-packages/datasift/historics.py", line 102, in status
    return self.request.get('status', params=params)
  File "/Library/Python/2.7/site-packages/datasift/request.py", line 39, in get
    return self.build_response(self('get', path, params=params, headers=headers), path=path)
  File "/Library/Python/2.7/site-packages/datasift/request.py", line 84, in build_response
    if int(response.headers.get("x-ratelimit-cost")) > int(response.headers.get("x-ratelimit-remaining")):
TypeError: int() argument must be a string or a number, not 'NoneType'

A new type of exception needs to be thrown when it sees '"error":"You do not have permission to access this endpoint"' as a response.

aneilbaboo commented 10 years ago

+1

I'm seeing this too.

paulmozo commented 9 years ago

This should now be fixed