# Buggy code
async def check_new_version_api(self, version_check_url):
    try:
        async with ClientSession(raise_for_status=True) as session:
            response = await session.get(version_check_url)
            response_dict = await response.json(content_type=None)
            version = response_dict["name"][1:]
            if LooseVersion(version) > LooseVersion(version_id):
                self.session.notifier.notify(NTFY.TRIBLER_NEW_VERSION, version)
                return True
            return False
    except (ServerConnectionError, ClientConnectionError) as e:
        self._logger.error("Error when performing version check request: %s", e)
        return False
    except ClientResponseError as e:
        self._logger.warning(
            "Got response code %s when performing version check request", e.status
        )
        return False
    except ContentTypeError:
        self._logger.warning("Response was not in JSON format")
        return False
    except asyncio.TimeoutError:
        self._logger.warning(
            "Checking for new version failed for %s", version_check_url
        )
        return False
    except ValueError as ve:
        raise ValueError("Failed to parse Tribler version response.\nError:%s" % ve)


# Traceback (RuntimeError)
Traceback (most recent call last):
File "src\tribler-gui\tribler_gui\event_request_manager.py", line 116, in on_read_data
RuntimeError: local variable 'response_dict' referenced before assignment
--LONG TEXT--
Traceback (most recent call last):
File "src\tribler-core\tribler_core\modules\versioncheck_manager.py", line 60, in check_new_version_api
UnboundLocalError: local variable 'response_dict' referenced before assignment

--CONTEXT--
{'message': 'Task exception was never retrieved', 'exception': UnboundLocalError("local variable 'response_dict' referenced before assignment"), 'future': <Task finished name='Task-171' coro=<VersionCheckManager.check_new_version_api() done, defined at src\tribler-core\tribler_core\modules\versioncheck_manager.py:42> exception=UnboundLocalError("local variable 'response_dict' referenced before assignment")>}

# Fixed code
async def check_new_version_api(self, version_check_url):
    try:
        async with ClientSession(raise_for_status=True) as session:
            response = await session.get(
                version_check_url, timeout=ClientTimeout(total=VERSION_CHECK_TIMEOUT)
            )
            response_dict = await response.json(content_type=None)
            version = response_dict["name"][1:]
            if LooseVersion(version) > LooseVersion(version_id):
                self.session.notifier.notify(NTFY.TRIBLER_NEW_VERSION, version)
                return True
            return False
    except (ServerConnectionError, ClientConnectionError) as e:
        self._logger.error("Error when performing version check request: %s", e)
        return False
    except ClientResponseError as e:
        self._logger.warning(
            "Got response code %s when performing version check request", e.status
        )
        return False
    except ContentTypeError:
        self._logger.warning("Response was not in JSON format")
        return False
    except asyncio.TimeoutError:
        self._logger.warning(
            "Checking for new version failed for %s", version_check_url
        )
        return False
    except ValueError as ve:
        raise ValueError("Failed to parse Tribler version response.\nError:%s" % ve)