Path: blob/master/venv/Lib/site-packages/requests/exceptions.py
811 views
# -*- coding: utf-8 -*-12"""3requests.exceptions4~~~~~~~~~~~~~~~~~~~56This module contains the set of Requests' exceptions.7"""8from urllib3.exceptions import HTTPError as BaseHTTPError91011class RequestException(IOError):12"""There was an ambiguous exception that occurred while handling your13request.14"""1516def __init__(self, *args, **kwargs):17"""Initialize RequestException with `request` and `response` objects."""18response = kwargs.pop('response', None)19self.response = response20self.request = kwargs.pop('request', None)21if (response is not None and not self.request and22hasattr(response, 'request')):23self.request = self.response.request24super(RequestException, self).__init__(*args, **kwargs)252627class HTTPError(RequestException):28"""An HTTP error occurred."""293031class ConnectionError(RequestException):32"""A Connection error occurred."""333435class ProxyError(ConnectionError):36"""A proxy error occurred."""373839class SSLError(ConnectionError):40"""An SSL error occurred."""414243class Timeout(RequestException):44"""The request timed out.4546Catching this error will catch both47:exc:`~requests.exceptions.ConnectTimeout` and48:exc:`~requests.exceptions.ReadTimeout` errors.49"""505152class ConnectTimeout(ConnectionError, Timeout):53"""The request timed out while trying to connect to the remote server.5455Requests that produced this error are safe to retry.56"""575859class ReadTimeout(Timeout):60"""The server did not send any data in the allotted amount of time."""616263class URLRequired(RequestException):64"""A valid URL is required to make a request."""656667class TooManyRedirects(RequestException):68"""Too many redirects."""697071class MissingSchema(RequestException, ValueError):72"""The URL schema (e.g. http or https) is missing."""737475class InvalidSchema(RequestException, ValueError):76"""See defaults.py for valid schemas."""777879class InvalidURL(RequestException, ValueError):80"""The URL provided was somehow invalid."""818283class InvalidHeader(RequestException, ValueError):84"""The header value provided was somehow invalid."""858687class InvalidProxyURL(InvalidURL):88"""The proxy URL provided is invalid."""899091class ChunkedEncodingError(RequestException):92"""The server declared chunked encoding but sent an invalid chunk."""939495class ContentDecodingError(RequestException, BaseHTTPError):96"""Failed to decode response content."""979899class StreamConsumedError(RequestException, TypeError):100"""The content for this response was already consumed."""101102103class RetryError(RequestException):104"""Custom retries logic failed"""105106107class UnrewindableBodyError(RequestException):108"""Requests encountered an error when trying to rewind a body."""109110# Warnings111112113class RequestsWarning(Warning):114"""Base warning for Requests."""115116117class FileModeWarning(RequestsWarning, DeprecationWarning):118"""A file was opened in text mode, but Requests determined its binary length."""119120121class RequestsDependencyWarning(RequestsWarning):122"""An imported dependency doesn't match the expected version range."""123124125