blob: 824a276f1738ce0ccf11cf3f8f95b83384e33601 [file] [log] [blame]
Barry Warsawc5f8fe32001-09-26 22:21:52 +00001\declaremodule{standard}{email.Errors}
Barry Warsaw5e634632001-09-26 05:23:47 +00002\modulesynopsis{The exception classes used by the email package.}
Barry Warsaw5e634632001-09-26 05:23:47 +00003
4The following exception classes are defined in the
5\module{email.Errors} module:
6
7\begin{excclassdesc}{MessageError}{}
8This is the base class for all exceptions that the \module{email}
9package can raise. It is derived from the standard
10\exception{Exception} class and defines no additional methods.
11\end{excclassdesc}
12
13\begin{excclassdesc}{MessageParseError}{}
14This is the base class for exceptions thrown by the \class{Parser}
15class. It is derived from \exception{MessageError}.
16\end{excclassdesc}
17
18\begin{excclassdesc}{HeaderParseError}{}
19Raised under some error conditions when parsing the \rfc{2822} headers of
20a message, this class is derived from \exception{MessageParseError}.
21It can be raised from the \method{Parser.parse()} or
22\method{Parser.parsestr()} methods.
23
Barry Warsaw5b9da892002-10-01 01:05:52 +000024Situations where it can be raised include finding an envelope
Barry Warsaw5e634632001-09-26 05:23:47 +000025header after the first \rfc{2822} header of the message, finding a
26continuation line before the first \rfc{2822} header is found, or finding
27a line in the headers which is neither a header or a continuation
28line.
29\end{excclassdesc}
30
31\begin{excclassdesc}{BoundaryError}{}
32Raised under some error conditions when parsing the \rfc{2822} headers of
33a message, this class is derived from \exception{MessageParseError}.
34It can be raised from the \method{Parser.parse()} or
35\method{Parser.parsestr()} methods.
36
37Situations where it can be raised include not being able to find the
Barry Warsaw5b9da892002-10-01 01:05:52 +000038starting or terminating boundary in a \mimetype{multipart/*} message
39when strict parsing is used.
Barry Warsaw5e634632001-09-26 05:23:47 +000040\end{excclassdesc}
41
42\begin{excclassdesc}{MultipartConversionError}{}
43Raised when a payload is added to a \class{Message} object using
44\method{add_payload()}, but the payload is already a scalar and the
Barry Warsawc5f8fe32001-09-26 22:21:52 +000045message's \mailheader{Content-Type} main type is not either
46\mimetype{multipart} or missing. \exception{MultipartConversionError}
47multiply inherits from \exception{MessageError} and the built-in
48\exception{TypeError}.
Barry Warsaw5b9da892002-10-01 01:05:52 +000049
50Since \method{Message.add_payload()} is deprecated, this exception is
51rarely raised in practice. However the exception may also be raised
52if the \method{attach()} method is called on an instance of a class
53derived from \class{MIMENonMultipart} (e.g. \class{MIMEImage}).
Barry Warsaw5e634632001-09-26 05:23:47 +000054\end{excclassdesc}