blob: e233219225da279feb273b2906ffeb4da68d1e37 [file] [log] [blame]
Barry Warsaw333e8302004-05-09 03:26:07 +00001# Copyright (C) 2001-2004 Python Software Foundation
2# Author: barry@python.org (Barry Warsaw)
Barry Warsawba925802001-09-23 03:17:28 +00003
Barry Warsaw333e8302004-05-09 03:26:07 +00004"""email package exception classes."""
Barry Warsawba925802001-09-23 03:17:28 +00005
6
Barry Warsawe968ead2001-10-04 17:05:11 +00007
Barry Warsawba925802001-09-23 03:17:28 +00008class MessageError(Exception):
Barry Warsawc5d1c042002-06-01 05:45:37 +00009 """Base class for errors in the email package."""
Barry Warsawba925802001-09-23 03:17:28 +000010
11
12class MessageParseError(MessageError):
13 """Base class for message parsing errors."""
14
15
16class HeaderParseError(MessageParseError):
17 """Error while parsing headers."""
18
19
20class BoundaryError(MessageParseError):
21 """Couldn't find terminating boundary."""
22
23
24class MultipartConversionError(MessageError, TypeError):
25 """Conversion to a multipart is prohibited."""
Barry Warsaw333e8302004-05-09 03:26:07 +000026
27
28
29# These are parsing defects which the parser was able to work around.
30class MessageDefect:
31 """Base class for a message defect."""
32
33 def __init__(self, line=None):
34 self.line = line
35
36class NoBoundaryInMultipart(MessageDefect):
37 """A message claimed to be a multipart but had no boundary parameter."""
38
39class StartBoundaryNotFound(MessageDefect):
40 """The claimed start boundary was never found."""
41
42class FirstHeaderLineIsContinuation(MessageDefect):
43 """A message had a continuation line as its first header line."""
44
45class MisplacedEnvelopeHeader(MessageDefect):
46 """A 'Unix-from' header was found in the middle of a header block."""
47
48class MalformedHeader(MessageDefect):
49 """Found a header that was missing a colon, or was otherwise malformed"""