| 1 | # Copyright (C) 2001-2006 Python Software Foundation
|
|---|
| 2 | # Author: Barry Warsaw
|
|---|
| 3 | # Contact: [email protected]
|
|---|
| 4 |
|
|---|
| 5 | """email package exception classes."""
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 | |
|---|
| 9 |
|
|---|
| 10 | class MessageError(Exception):
|
|---|
| 11 | """Base class for errors in the email package."""
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 | class MessageParseError(MessageError):
|
|---|
| 15 | """Base class for message parsing errors."""
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 | class HeaderParseError(MessageParseError):
|
|---|
| 19 | """Error while parsing headers."""
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 | class BoundaryError(MessageParseError):
|
|---|
| 23 | """Couldn't find terminating boundary."""
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 | class MultipartConversionError(MessageError, TypeError):
|
|---|
| 27 | """Conversion to a multipart is prohibited."""
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 | class CharsetError(MessageError):
|
|---|
| 31 | """An illegal charset was given."""
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 | |
|---|
| 35 |
|
|---|
| 36 | # These are parsing defects which the parser was able to work around.
|
|---|
| 37 | class MessageDefect:
|
|---|
| 38 | """Base class for a message defect."""
|
|---|
| 39 |
|
|---|
| 40 | def __init__(self, line=None):
|
|---|
| 41 | self.line = line
|
|---|
| 42 |
|
|---|
| 43 | class NoBoundaryInMultipartDefect(MessageDefect):
|
|---|
| 44 | """A message claimed to be a multipart but had no boundary parameter."""
|
|---|
| 45 |
|
|---|
| 46 | class StartBoundaryNotFoundDefect(MessageDefect):
|
|---|
| 47 | """The claimed start boundary was never found."""
|
|---|
| 48 |
|
|---|
| 49 | class FirstHeaderLineIsContinuationDefect(MessageDefect):
|
|---|
| 50 | """A message had a continuation line as its first header line."""
|
|---|
| 51 |
|
|---|
| 52 | class MisplacedEnvelopeHeaderDefect(MessageDefect):
|
|---|
| 53 | """A 'Unix-from' header was found in the middle of a header block."""
|
|---|
| 54 |
|
|---|
| 55 | class MalformedHeaderDefect(MessageDefect):
|
|---|
| 56 | """Found a header that was missing a colon, or was otherwise malformed."""
|
|---|
| 57 |
|
|---|
| 58 | class MultipartInvariantViolationDefect(MessageDefect):
|
|---|
| 59 | """A message claimed to be a multipart but no subparts were found."""
|
|---|