2008-06-23 01:41:59 -03:00
|
|
|
:mod:`urllib.error` --- Exception classes raised by urllib.request
|
|
|
|
==================================================================
|
|
|
|
|
|
|
|
.. module:: urllib.error
|
2008-06-23 08:23:31 -03:00
|
|
|
:synopsis: Exception classes raised by urllib.request.
|
2008-06-23 01:41:59 -03:00
|
|
|
.. moduleauthor:: Jeremy Hylton <jhylton@users.sourceforge.net>
|
|
|
|
.. sectionauthor:: Senthil Kumaran <orsenthil@gmail.com>
|
|
|
|
|
|
|
|
|
2008-06-23 08:23:31 -03:00
|
|
|
The :mod:`urllib.error` module defines the exception classes for exceptions
|
|
|
|
raised by :mod:`urllib.request`. The base exception class is :exc:`URLError`,
|
|
|
|
which inherits from :exc:`IOError`.
|
2008-06-23 01:41:59 -03:00
|
|
|
|
|
|
|
The following exceptions are raised by :mod:`urllib.error` as appropriate:
|
|
|
|
|
|
|
|
.. exception:: URLError
|
|
|
|
|
2008-06-23 08:23:31 -03:00
|
|
|
The handlers raise this exception (or derived exceptions) when they run into
|
|
|
|
a problem. It is a subclass of :exc:`IOError`.
|
2008-06-23 01:41:59 -03:00
|
|
|
|
|
|
|
.. attribute:: reason
|
|
|
|
|
2008-06-23 08:23:31 -03:00
|
|
|
The reason for this error. It can be a message string or another
|
|
|
|
exception instance (:exc:`socket.error` for remote URLs, :exc:`OSError`
|
|
|
|
for local URLs).
|
2008-06-23 01:41:59 -03:00
|
|
|
|
|
|
|
|
|
|
|
.. exception:: HTTPError
|
|
|
|
|
2008-06-23 08:23:31 -03:00
|
|
|
Though being an exception (a subclass of :exc:`URLError`), an
|
|
|
|
:exc:`HTTPError` can also function as a non-exceptional file-like return
|
|
|
|
value (the same thing that :func:`urlopen` returns). This is useful when
|
|
|
|
handling exotic HTTP errors, such as requests for authentication.
|
2008-06-23 01:41:59 -03:00
|
|
|
|
|
|
|
.. attribute:: code
|
|
|
|
|
2008-06-23 08:23:31 -03:00
|
|
|
An HTTP status code as defined in `RFC 2616
|
|
|
|
<http://www.faqs.org/rfcs/rfc2616.html>`_. This numeric value corresponds
|
|
|
|
to a value found in the dictionary of codes as found in
|
|
|
|
:attr:`http.server.BaseHTTPRequestHandler.responses`.
|
2008-06-23 01:41:59 -03:00
|
|
|
|
|
|
|
.. exception:: ContentTooShortError(msg[, content])
|
|
|
|
|
2008-06-23 08:23:31 -03:00
|
|
|
This exception is raised when the :func:`urlretrieve` function detects that
|
|
|
|
the amount of the downloaded data is less than the expected amount (given by
|
|
|
|
the *Content-Length* header). The :attr:`content` attribute stores the
|
|
|
|
downloaded (and supposedly truncated) data.
|
2008-06-23 01:41:59 -03:00
|
|
|
|