def handle_errors ( resp ) : if resp . status_code == 400 : raise ApiException ( json . loads ( resp . content ) . get ( 'message' ) ) return resp
python restful how to process errors
raise a descriptive exception on a bad request response
def handle_errors(resp):
    """raise a descriptive exception on a "bad request" response"""
    if resp.status_code == 400:
        raise ApiException(json.loads(resp.content).get('message'))
    return resp