Some helpful error messages would be lovely, as currently they all just fall right through, like so:
❯ poetry run python src/mdut.py foo://bar
Traceback (most recent call last):
File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
yield
File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_transports/default.py", line 187, in handle_request
resp = self._pool.handle_request(req)
File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpcore/_sync/connection_pool.py", line 216, in handle_request
raise UnsupportedProtocol(
httpcore.UnsupportedProtocol: Request URL has an unsupported protocol 'foo://'.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/nik/src/nkantar/mdut/src/mdut.py", line 68, in <module>
mdut()
File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/Users/nik/src/nkantar/mdut/src/mdut.py", line 61, in mdut
tag = markdown_url_tag(url, style)
File "/Users/nik/src/nkantar/mdut/src/mdut.py", line 39, in markdown_url_tag
html = fetch_html(url)
File "/Users/nik/src/nkantar/mdut/src/mdut.py", line 20, in fetch_html
return httpx.get(url).text
File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_api.py", line 189, in get
return request(
File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_api.py", line 100, in request
return client.request(
File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 802, in request
return self.send(request, auth=auth, follow_redirects=follow_redirects)
File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 889, in send
response = self._send_handling_auth(
File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 917, in _send_handling_auth
response = self._send_handling_redirects(
File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 954, in _send_handling_redirects
response = self._send_single_request(request)
File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_client.py", line 990, in _send_single_request
response = transport.handle_request(request)
File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_transports/default.py", line 186, in handle_request
with map_httpcore_exceptions():
File "/opt/homebrew/Cellar/[email protected]/3.10.1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/contextlib.py", line 153, in __exit__
self.gen.throw(typ, value, traceback)
File "/Users/nik/Library/Caches/pypoetry/virtualenvs/mdut-kQOfudX7-py3.10/lib/python3.10/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.UnsupportedProtocol: Request URL has an unsupported protocol 'foo://'.
enhancement