exceptions.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # -*- coding: utf-8 -*-
  2. """
  3. requests.exceptions
  4. ~~~~~~~~~~~~~~~~~~~
  5. This module contains the set of Requests' exceptions.
  6. """
  7. class RequestException(IOError):
  8. """There was an ambiguous exception that occurred while handling your
  9. request."""
  10. class HTTPError(RequestException):
  11. """An HTTP error occurred."""
  12. def __init__(self, *args, **kwargs):
  13. """ Initializes HTTPError with optional `response` object. """
  14. self.response = kwargs.pop('response', None)
  15. super(HTTPError, self).__init__(*args, **kwargs)
  16. class ConnectionError(RequestException):
  17. """A Connection error occurred."""
  18. class SSLError(ConnectionError):
  19. """An SSL error occurred."""
  20. class Timeout(RequestException):
  21. """The request timed out."""
  22. class URLRequired(RequestException):
  23. """A valid URL is required to make a request."""
  24. class TooManyRedirects(RequestException):
  25. """Too many redirects."""
  26. class MissingSchema(RequestException, ValueError):
  27. """The URL schema (e.g. http or https) is missing."""
  28. class InvalidSchema(RequestException, ValueError):
  29. """See defaults.py for valid schemas."""
  30. class InvalidURL(RequestException, ValueError):
  31. """ The URL provided was somehow invalid. """
  32. class ChunkedEncodingError(RequestException):
  33. """The server declared chunked encoding but sent an invalid chunk."""