def throw_if_bad_response(response):
    """Throw an exception if the Cerberus response is not successful."""
    try:
        response.raise_for_status()
    except RequestException:
        try:
            msg = 'Response code: {}; response body:\n{}'.format(response.status_code, json.dumps(response.json(), indent=2))
            raise CerberusClientException(msg)
        except ValueError:
            msg = 'Response code: {}; response body:\n{}'.format(response.status_code, response.text)
            raise CerberusClientException(msg)
def throw_if_bad_response ( response ) : try : response . raise_for_status ( ) except RequestException : try : msg = 'Response code: {}; response body:\n{}' . format ( response . status_code , json . dumps ( response . json ( ) , indent = 2 ) ) raise CerberusClientException ( msg ) except ValueError : msg = 'Response code: {}; response body:\n{}' . format ( response . status_code , response . text ) raise CerberusClientException ( msg )
Throw an exception if the Cerberus response is not successful.