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