blob: 1cbfe7d8eb47b9510ce69efa912c0cddc11237f0 [file] [log] [blame]
Senthil Kumaranaca8fd72008-06-23 04:41:59 +00001:mod:`urllib.error` --- Exception classes raised by urllib.request
2==================================================================
3
4.. module:: urllib.error
5 :synopsis: Next generation URL opening library.
6.. moduleauthor:: Jeremy Hylton <jhylton@users.sourceforge.net>
7.. sectionauthor:: Senthil Kumaran <orsenthil@gmail.com>
8
9
10The :mod:`urllib.error` module defines exception classes raise by
11urllib.request. The base exception class is URLError, which inherits from
12IOError.
13
14The following exceptions are raised by :mod:`urllib.error` as appropriate:
15
16
17.. exception:: URLError
18
19 The handlers raise this exception (or derived exceptions) when they run into a
20 problem. It is a subclass of :exc:`IOError`.
21
22 .. attribute:: reason
23
24 The reason for this error. It can be a message string or another exception
25 instance (:exc:`socket.error` for remote URLs, :exc:`OSError` for local
26 URLs).
27
28
29.. exception:: HTTPError
30
31 Though being an exception (a subclass of :exc:`URLError`), an :exc:`HTTPError`
32 can also function as a non-exceptional file-like return value (the same thing
33 that :func:`urlopen` returns). This is useful when handling exotic HTTP
34 errors, such as requests for authentication.
35
36 .. attribute:: code
37
38 An HTTP status code as defined in `RFC 2616 <http://www.faqs.org/rfcs/rfc2616.html>`_.
39 This numeric value corresponds to a value found in the dictionary of
40 codes as found in :attr:`http.server.BaseHTTPRequestHandler.responses`.
41
42.. exception:: ContentTooShortError(msg[, content])
43
44 This exception is raised when the :func:`urlretrieve` function detects that the
45 amount of the downloaded data is less than the expected amount (given by the
46 *Content-Length* header). The :attr:`content` attribute stores the downloaded
47 (and supposedly truncated) data.
48