code: def validate_response(response):
      """
      Raise a helpful PlotlyRequestError for failed requests.
  
      :param (requests.Response) response: A Response object from an api request.
      :raises: (PlotlyRequestError) If the request failed for any reason.
      :returns: (None)
  
      """
      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)
  
file_path: plotly.py/packages/python/chart-studio/chart_studio/api/v2/utils.py
imports: from __future__ import absolute_import
  import requests
  import json
  from requests.exceptions import RequestException
  from retrying import retry
  import _plotly_utils.exceptions
  from chart_studio import config, exceptions
  from chart_studio.api.utils import basic_auth
  from _plotly_utils.utils import PlotlyJSONEncoder
label_desc: Use image node_id 3 for calling a global function with example usage: validate_response(response) without return types