Errors and exceptions

Different types of errors and exceptions will be raised when something goes wrong in the process of sending a request and getting back a response. Some of them are as follows:

  • HTTPError: When there are invalid HTTP responses, Requests will raise an HTTPError exception
  • ConnectionError: If there is a network problem, such as refused connection and DNS failure, Requests will raise a ConnectionError exception
  • Timeout: If the request gets timed out, this exception will be raised
  • TooManyRedirects: If the request surpasses the configured number of maximum redirections, this type of exception is raised

Other types of exception that come in to the picture are Missing schema Exception, InvalidURL, ChunkedEncodingError, and ContentDecodingError and so on.

This example has been taken from Request documents available at http://docs.python-requests.org/en/latest/user/quickstart/#errors-and-exceptions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.244.250