Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aiohttp.errors is gone #1753

Closed
jwilk opened this issue Mar 25, 2017 · 7 comments
Closed

aiohttp.errors is gone #1753

jwilk opened this issue Mar 25, 2017 · 7 comments
Labels

Comments

@jwilk
Copy link
Contributor

jwilk commented Mar 25, 2017

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

@AraHaan
Copy link
Contributor

AraHaan commented Mar 25, 2017

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__']
>>>

@fafhrd91
Copy link
Member

aiohttp.errors was never ment to be used directly

@AraHaan
Copy link
Contributor

AraHaan commented Mar 25, 2017

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 added a commit to jwilk/urlycue that referenced this issue Mar 25, 2017
Fixes:

    AttributeError: module 'aiohttp' has no attribute 'errors'

aio-libs/aiohttp#1753
@fafhrd91
Copy link
Member

@jwilk updated are updated

@bartaelterman
Copy link

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

@fafhrd91
Copy link
Member

Something like this should be enough:

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

@lock
Copy link

lock bot commented Oct 28, 2019

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.

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants