def handle_response(self, response, url): try: json_data = json.loads(response) except InvalidJson as exc: raise InvalidResponseException(exc.message) if 'url' not in json_data: json_data['url'] = url if 'title' not in json_data: json_data['title'] = json_data['url'] return json_data
def handle_response(self, response, url): try: json_data = json.loads(response) except InvalidJson as exc: try: msg = exc.message except AttributeError: msg = exc.args[0] raise InvalidResponseException(msg) if 'url' not in json_data: json_data['url'] = url if 'title' not in json_data: json_data['title'] = json_data['url'] return json_data