/usr/lib/python2.7/dist-packages/fitbit/exceptions.py is in python-fitbit 0.1.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | import json
class BadResponse(Exception):
"""
Currently used if the response can't be json encoded, despite a .json extension
"""
pass
class DeleteError(Exception):
"""
Used when a delete request did not return a 204
"""
pass
class HTTPException(Exception):
def __init__(self, response, *args, **kwargs):
try:
errors = json.loads(response.content.decode('utf8'))['errors']
message = '\n'.join([error['message'] for error in errors])
except Exception:
if hasattr(response, 'status_code') and response.status_code == 401:
message = response.content.decode('utf8')
else:
message = response
super(HTTPException, self).__init__(message, *args, **kwargs)
class HTTPBadRequest(HTTPException):
"""Generic >= 400 error
"""
pass
class HTTPUnauthorized(HTTPException):
"""401
"""
pass
class HTTPForbidden(HTTPException):
"""403
"""
pass
class HTTPNotFound(HTTPException):
"""404
"""
pass
class HTTPConflict(HTTPException):
"""409 - returned when creating conflicting resources
"""
pass
class HTTPTooManyRequests(HTTPException):
"""429 - returned when exceeding rate limits
"""
pass
class HTTPServerError(HTTPException):
"""Generic >= 500 error
"""
pass
|