python
network_error
ai_generated
true
aiohttp.client_exceptions.ClientResponseError: 404, message='Not Found', url=URL('http://example.com/nonexistent')
ID: python/aiohttp-client-http-error
80%Fix Rate
86%Confidence
0Evidence
2025-06-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.7 | active | — | — | — |
| 3.8 | active | — | — | — |
Root Cause
The server returns a 4xx or 5xx status code, and aiohttp raises an exception if raise_for_status is called.
generic中文
服务器返回4xx或5xx状态码,如果调用raise_for_status,aiohttp会引发异常。
Workarounds
-
95% success
if resp.status != 200: raise Exception(f'HTTP {resp.status}') -
90% success
try: resp.raise_for_status() except aiohttp.ClientResponseError as e: print(e.status)
Dead Ends
Common approaches that don't work:
-
60% fail
The error is raised by raise_for_status(); if you don't call it, no exception occurs.
-
80% fail
The resource doesn't exist; changing method won't help.