blob: d52a624601f09216ba49f727c6b3fd1853b9ef68 [file] [log] [blame]
Barry Warsaw40ef0062006-03-18 15:41:53 +00001# Copyright (C) 2001-2006 Python Software Foundation
Barry Warsawbb113862004-10-03 03:16:19 +00002# Author: Barry Warsaw
3# Contact: email-sig@python.org
Barry Warsawba925802001-09-23 03:17:28 +00004
Barry Warsaw333e8302004-05-09 03:26:07 +00005"""email package exception classes."""
Barry Warsawba925802001-09-23 03:17:28 +00006
7
Barry Warsawe968ead2001-10-04 17:05:11 +00008
Barry Warsawba925802001-09-23 03:17:28 +00009class MessageError(Exception):
Barry Warsawc5d1c042002-06-01 05:45:37 +000010 """Base class for errors in the email package."""
Barry Warsawba925802001-09-23 03:17:28 +000011
12
13class MessageParseError(MessageError):
14 """Base class for message parsing errors."""
15
16
17class HeaderParseError(MessageParseError):
18 """Error while parsing headers."""
19
20
21class BoundaryError(MessageParseError):
22 """Couldn't find terminating boundary."""
23
24
25class MultipartConversionError(MessageError, TypeError):
26 """Conversion to a multipart is prohibited."""
Barry Warsaw333e8302004-05-09 03:26:07 +000027
28
Barry Warsaw40ef0062006-03-18 15:41:53 +000029class CharsetError(MessageError):
30 """An illegal charset was given."""
31
32
Barry Warsaw333e8302004-05-09 03:26:07 +000033
34# These are parsing defects which the parser was able to work around.
35class MessageDefect:
36 """Base class for a message defect."""
37
38 def __init__(self, line=None):
39 self.line = line
40
Barry Warsawbb113862004-10-03 03:16:19 +000041class NoBoundaryInMultipartDefect(MessageDefect):
Barry Warsaw333e8302004-05-09 03:26:07 +000042 """A message claimed to be a multipart but had no boundary parameter."""
43
Barry Warsawbb113862004-10-03 03:16:19 +000044class StartBoundaryNotFoundDefect(MessageDefect):
Barry Warsaw333e8302004-05-09 03:26:07 +000045 """The claimed start boundary was never found."""
46
Barry Warsawbb113862004-10-03 03:16:19 +000047class FirstHeaderLineIsContinuationDefect(MessageDefect):
Barry Warsaw333e8302004-05-09 03:26:07 +000048 """A message had a continuation line as its first header line."""
49
Barry Warsawbb113862004-10-03 03:16:19 +000050class MisplacedEnvelopeHeaderDefect(MessageDefect):
Barry Warsaw333e8302004-05-09 03:26:07 +000051 """A 'Unix-from' header was found in the middle of a header block."""
52
Barry Warsawbb113862004-10-03 03:16:19 +000053class MalformedHeaderDefect(MessageDefect):
54 """Found a header that was missing a colon, or was otherwise malformed."""
55
56class MultipartInvariantViolationDefect(MessageDefect):
57 """A message claimed to be a multipart but no subparts were found."""