aiohttp.errors is gone

Created on 25 Mar 2017  路  7Comments  路  Source: aio-libs/aiohttp

Long story short

The aiohttp.errors module used to be public, documented API.
Now it's gone.

If this backwards-incompatible change is intentional, then it should be documented.

Steps to reproduce

$ python3 -c 'import aiohttp.errors'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named 'aiohttp.errors'

$ grep -Fcw aiohttp.errors CHANGES.rst HISTORY.rst 
CHANGES.rst:0
HISTORY.rst:0

Your environment

aiohttp 2.0.3

outdated

Most helpful comment

Something like this should be enough:

try:
    yield from aiohttp.request()
except aiohttp.ClientError as err:
    print(err)

All 7 comments

yeah it sucks not being able to handle aiohttp exceptions if you wanted to. Unless I pull an hack and do this from aiohttp import errors.

Python 3.6.0rc1 (v3.6.0rc1:29a273eee9a5, Dec  7 2016, 04:31:34) [MSC v.1900 32 b
it (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import aiohttp
>>> aiohttp.errors
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'aiohttp' has no attribute 'errors'
>>> from aiohttp import errors
>>> dir(errors)
['BadHttpMessage', 'BadStatusLine', 'ClientConnectionError', 'ClientDisconnected
Error', 'ClientError', 'ClientHttpProcessingError', 'ClientOSError', 'ClientRequ
estError', 'ClientResponseError', 'ClientTimeoutError', 'ContentEncodingError',
'DisconnectedError', 'FingerprintMismatch', 'HttpBadRequest', 'HttpMethodNotAllo
wed', 'HttpProcessingError', 'HttpProxyError', 'InvalidHeader', 'LineLimitExceed
edParserError', 'LineTooLong', 'ProxyConnectionError', 'ServerDisconnectedError'
, 'TimeoutError', 'TransferEncodingError', 'WSServerHandshakeError', '__all__',
'__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '
__package__', '__spec__']
>>>

aiohttp.errors was never ment to be used directly

Except when you want to handle aiohttp exceptions in another library (discord.py is one of those libraries) to know when you get an 200, 404, or w/e error code it returns or when the request was bad / invalid. They also use ServerDisconnectedError to know when to reconnect. (the service the library covers has an HEARTBEAT_ACK)

@jwilk updated are updated

@fafhrd91 if your code raises those errors, why shouldn't we import them directly so we can catch them?

Something like this should be enough:

try:
    yield from aiohttp.request()
except aiohttp.ClientError as err:
    print(err)

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a [new issue] for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that [new issue].

Was this page helpful?
0 / 5 - 0 ratings