Log :exc:`urllib.error.HTTPError`, converting to
        GraphQL's ``{"data": null, "errors": [{"message": str(exc)...}]}``

        :param query: the GraphQL query that triggered the result.
        :type query: str

        :param req: :class:`urllib.request.Request` instance that was opened.
        :type req: :class:`urllib.request.Request`

        :param exc: :exc:`urllib.error.HTTPError` instance
        :type exc: :exc:`urllib.error.HTTPError`

        :return: GraphQL-compliant dict with keys ``data`` and ``errors``.
        :rtype: dict

def _log_http_error(self, query, req, exc):
        '''Log :exc:`urllib.error.HTTPError`, converting to
        GraphQL's ``{"data": null, "errors": [{"message": str(exc)...}]}``

        :param query: the GraphQL query that triggered the result.
        :type query: str

        :param req: :class:`urllib.request.Request` instance that was opened.
        :type req: :class:`urllib.request.Request`

        :param exc: :exc:`urllib.error.HTTPError` instance
        :type exc: :exc:`urllib.error.HTTPError`

        :return: GraphQL-compliant dict with keys ``data`` and ``errors``.
        :rtype: dict
        '''
        self.logger.error('%s: %s', req.get_full_url(), exc)
        for h in sorted(exc.headers):
            self.logger.info('Response header: %s: %s', h, exc.headers[h])

        body = exc.read().decode('utf-8')
        content_type = exc.headers.get('Content-Type', '')
        self.logger.info('Response [%s]:\n%s', content_type, body)
        if not content_type.startswith('application/json'):
            return {'data': None, 'errors': [{
                'message': str(exc),
                'exception': exc,
                'status': exc.code,
                'headers': exc.headers,
                'body': body,
            }]}
        else:
            # GraphQL servers return 400 and {'errors': [...]}
            # if only errors was returned, no {'data': ...}
            try:
                data = json.loads(body)
            except json.JSONDecodeError as exc:
                return self._log_json_error(body, exc)

            if isinstance(data, dict) and data.get('errors'):
                data.update({
                    'exception': exc,
                    'status': exc.code,
                    'headers': exc.headers,
                })
                return self._log_graphql_error(query, data)
            return {'data': None, 'errors': [{
                'message': str(exc),
                'exception': exc,
                'status': exc.code,
                'headers': exc.headers,
                'body': body,
            }]}