Session.get and session.post throw an AssertionError when URL scheme is invalid

I’m developing a django app that comminucates with an API that we have also developed. I’m trying to neatly handle any possible errors, so I can log and display what’s going on. However when I write a URL with an invalid scheme I get an AssertionError back from aiohttp. Ideally I would prefer to avoid catching such rather generic errors if at all possible.

Is there a better way to catch this error?

async def aiohttp_call(num):
    async with aiohttp.ClientSession(raise_for_status=True) as session:
        url = f"ttps://pokeapi.co/api/v2/pokemon/{num}"
        async with session.get(url) as res:
            result = await res.json()
            return result["name"]

async_to_sync(aiohttp_call)(1)

traceback:

python test_url.py
Traceback (most recent call last):
  File "test_url.py", line 98, in <module>
    async_to_sync(aiohttp_call)(1)
  File "lib\site-packages\asgiref\sync.py", line 204, in __call__
    return call_result.result()
  File "C:\Users\uczmh2\AppData\Local\Programs\Python\Python39\lib\concurrent\futures\_base.py", line 433, in result
    return self.__get_result()
  File "C:\Users\uczmh2\AppData\Local\Programs\Python\Python39\lib\concurrent\futures\_base.py", line 389, in __get_result
    raise self._exception
  File "lib\site-packages\asgiref\sync.py", line 270, in main_wrap
    result = await self.awaitable(*args, **kwargs)
  File "test_url.py", line 94, in aiohttp_call
    async with session.get(url) as res:
  File "lib\site-packages\aiohttp\client.py", line 1138, in __aenter__
    self._resp = await self._coro
  File "lib\site-packages\aiohttp\client.py", line 535, in _request
    conn = await self._connector.connect(
  File "lib\site-packages\aiohttp\connector.py", line 542, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "lib\site-packages\aiohttp\connector.py", line 907, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "lib\site-packages\aiohttp\connector.py", line 1146, in _create_direct_connection
    assert port is not None
AssertionError