exceptions.py — requests Source File
Architecture documentation for exceptions.py, a python file in the requests codebase. 2 imports, 5 dependents.
Entity Profile
Dependency Diagram
graph LR f4a2f4ac_0336_89fc_eb3c_2c88c34f05a8["exceptions.py"] 655589d9_9504_8132_6277_d047dcd65486["compat.py"] f4a2f4ac_0336_89fc_eb3c_2c88c34f05a8 --> 655589d9_9504_8132_6277_d047dcd65486 3553b178_6549_f13d_615a_050813f5c27c["urllib3.exceptions"] f4a2f4ac_0336_89fc_eb3c_2c88c34f05a8 --> 3553b178_6549_f13d_615a_050813f5c27c 961d4893_d7e8_96e8_b607_9aeb34411448["__init__.py"] 961d4893_d7e8_96e8_b607_9aeb34411448 --> f4a2f4ac_0336_89fc_eb3c_2c88c34f05a8 8cafec3a_816a_3b74_357a_0167321e5d19["adapters.py"] 8cafec3a_816a_3b74_357a_0167321e5d19 --> f4a2f4ac_0336_89fc_eb3c_2c88c34f05a8 461bc6e0_32e7_8eab_ec87_7226e7be0d13["models.py"] 461bc6e0_32e7_8eab_ec87_7226e7be0d13 --> f4a2f4ac_0336_89fc_eb3c_2c88c34f05a8 ea1101aa_233b_1206_7b38_a38f0fe92a52["sessions.py"] ea1101aa_233b_1206_7b38_a38f0fe92a52 --> f4a2f4ac_0336_89fc_eb3c_2c88c34f05a8 2c39b9da_e317_5e6c_bbac_8362bac2110c["utils.py"] 2c39b9da_e317_5e6c_bbac_8362bac2110c --> f4a2f4ac_0336_89fc_eb3c_2c88c34f05a8 style f4a2f4ac_0336_89fc_eb3c_2c88c34f05a8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""
requests.exceptions
~~~~~~~~~~~~~~~~~~~
This module contains the set of Requests' exceptions.
"""
from urllib3.exceptions import HTTPError as BaseHTTPError
from .compat import JSONDecodeError as CompatJSONDecodeError
class RequestException(IOError):
"""There was an ambiguous exception that occurred while handling your
request.
"""
def __init__(self, *args, **kwargs):
"""Initialize RequestException with `request` and `response` objects."""
response = kwargs.pop("response", None)
self.response = response
self.request = kwargs.pop("request", None)
if response is not None and not self.request and hasattr(response, "request"):
self.request = self.response.request
super().__init__(*args, **kwargs)
class InvalidJSONError(RequestException):
"""A JSON error occurred."""
class JSONDecodeError(InvalidJSONError, CompatJSONDecodeError):
"""Couldn't decode the text into json"""
def __init__(self, *args, **kwargs):
"""
Construct the JSONDecodeError instance first with all
args. Then use it's args to construct the IOError so that
the json specific args aren't used as IOError specific args
and the error message from JSONDecodeError is preserved.
"""
CompatJSONDecodeError.__init__(self, *args)
InvalidJSONError.__init__(self, *self.args, **kwargs)
def __reduce__(self):
"""
The __reduce__ method called when pickling the object must
be the one from the JSONDecodeError (be it json/simplejson)
as it expects all the arguments for instantiation, not just
one like the IOError, and the MRO would by default call the
__reduce__ method from the IOError due to the inheritance order.
"""
return CompatJSONDecodeError.__reduce__(self)
class HTTPError(RequestException):
"""An HTTP error occurred."""
class ConnectionError(RequestException):
// ... (93 more lines)
Domain
Subdomains
Classes
- ChunkedEncodingError
- ConnectTimeout
- ConnectionError
- ContentDecodingError
- FileModeWarning
- HTTPError
- InvalidHeader
- InvalidJSONError
- InvalidProxyURL
- InvalidSchema
- InvalidURL
- JSONDecodeError
- MissingSchema
- ProxyError
- ReadTimeout
- RequestException
- RequestsDependencyWarning
- RequestsWarning
- RetryError
- SSLError
- StreamConsumedError
- Timeout
- TooManyRedirects
- URLRequired
- UnrewindableBodyError
Dependencies
- compat.py
- urllib3.exceptions
Imported By
Source
Frequently Asked Questions
What does exceptions.py do?
exceptions.py is a source file in the requests codebase, written in python. It belongs to the CoreAPI domain, SessionLifecycle subdomain.
What does exceptions.py depend on?
exceptions.py imports 2 module(s): compat.py, urllib3.exceptions.
What files import exceptions.py?
exceptions.py is imported by 5 file(s): __init__.py, adapters.py, models.py, sessions.py, utils.py.
Where is exceptions.py in the architecture?
exceptions.py is located at src/requests/exceptions.py (domain: CoreAPI, subdomain: SessionLifecycle, directory: src/requests).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free