code: def format_error(error: "GraphQLError") -> dict:
      
      if not error:
          raise ValueError("Received null or undefined error.")
      formatted: Dict[str, Any] = dict(  # noqa: E701 (pycqa/flake8#394)
          message=error.message or "An unknown error occurred.",
          locations=error.locations,
          path=error.path,
      )
      if error.extensions:
          formatted.update(extensions=error.extensions)
      return formatted
docs: Format a GraphQL error
  
      Given a GraphQLError, format it according to the rules described by the "Response
      Format, Errors" section of the GraphQL Specification.