

def raise_for_error(response):
    try:
        response.raise_for_status()
    except (requests.HTTPError, requests.ConnectionError) as error:
        try:
            if (len(response.content) == 0):
                return
            response = response.json()
            if (('error' in response) or ('errorCode' in response)):
                message = ('%s: %s' % (response.get('error', str(error)), response.get('message', 'Unknown Error')))
                error_code = response.get('status')
                ex = get_exception_for_error_code(error_code)
                raise ex(message)
            else:
                raise LinkedInError(error.message)
        except (ValueError, TypeError):
            raise LinkedInError(error.message)

dataset/ETHPy150Open ozgur/python-linkedin/linkedin/utils.py raise_for_error/original