def validate_response(response):
 if response.ok:
  return
 content = response.content
 status_code = response.status_code
 try:
  parsed_content = response.json()
 except ValueError:
  message = (content if content else 'No Content')
  raise exceptions.PlotlyRequestError(message, status_code, content)
 message = ''
 if isinstance(parsed_content, dict):
  errors = parsed_content.get('errors', [])
  messages = [error.get('message') for error in errors]
  message = '\n'.join([msg for msg in messages if msg])
 if (not message):
  message = (content if content else 'No Content')
 raise exceptions.PlotlyRequestError(message, status_code, content)

def validate_response ( response ) : if response . ok : return content = response . content status_code = response . status_code try : parsed_content = response . json ( ) except ValueError : message = ( content if content else 'No Content' ) raise exceptions . PlotlyRequestError ( message , status_code , content ) message = '' if isinstance ( parsed_content , dict ) : errors = parsed_content . get ( 'errors' , [ ] ) messages = [ error . get ( 'message' ) for error in errors ] message = '\n' . join ( [ msg for msg in messages if msg ] ) if ( not message ) : message = ( content if content else 'No Content' ) raise exceptions . PlotlyRequestError ( message , status_code , content )
raise a helpful plotlyrequesterror for failed requests .