2006-03-18 11:41:53 -04:00
|
|
|
|
# Copyright (C) 2001-2006 Python Software Foundation
|
2004-10-03 00:16:19 -03:00
|
|
|
|
# Author: Barry Warsaw
|
|
|
|
|
# Contact: email-sig@python.org
|
2001-09-23 00:17:28 -03:00
|
|
|
|
|
2004-05-09 00:26:07 -03:00
|
|
|
|
"""email package exception classes."""
|
2001-09-23 00:17:28 -03:00
|
|
|
|
|
|
|
|
|
|
2001-10-04 14:05:11 -03:00
|
|
|
|
|
2001-09-23 00:17:28 -03:00
|
|
|
|
class MessageError(Exception):
|
2002-06-01 02:45:37 -03:00
|
|
|
|
"""Base class for errors in the email package."""
|
2001-09-23 00:17:28 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MessageParseError(MessageError):
|
|
|
|
|
"""Base class for message parsing errors."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class HeaderParseError(MessageParseError):
|
|
|
|
|
"""Error while parsing headers."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BoundaryError(MessageParseError):
|
|
|
|
|
"""Couldn't find terminating boundary."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MultipartConversionError(MessageError, TypeError):
|
|
|
|
|
"""Conversion to a multipart is prohibited."""
|
2004-05-09 00:26:07 -03:00
|
|
|
|
|
|
|
|
|
|
2006-03-18 11:41:53 -04:00
|
|
|
|
class CharsetError(MessageError):
|
|
|
|
|
"""An illegal charset was given."""
|
|
|
|
|
|
|
|
|
|
|
2004-05-09 00:26:07 -03:00
|
|
|
|
|
|
|
|
|
# These are parsing defects which the parser was able to work around.
|
|
|
|
|
class MessageDefect:
|
|
|
|
|
"""Base class for a message defect."""
|
|
|
|
|
|
|
|
|
|
def __init__(self, line=None):
|
|
|
|
|
self.line = line
|
|
|
|
|
|
2004-10-03 00:16:19 -03:00
|
|
|
|
class NoBoundaryInMultipartDefect(MessageDefect):
|
2004-05-09 00:26:07 -03:00
|
|
|
|
"""A message claimed to be a multipart but had no boundary parameter."""
|
|
|
|
|
|
2004-10-03 00:16:19 -03:00
|
|
|
|
class StartBoundaryNotFoundDefect(MessageDefect):
|
2004-05-09 00:26:07 -03:00
|
|
|
|
"""The claimed start boundary was never found."""
|
|
|
|
|
|
2004-10-03 00:16:19 -03:00
|
|
|
|
class FirstHeaderLineIsContinuationDefect(MessageDefect):
|
2004-05-09 00:26:07 -03:00
|
|
|
|
"""A message had a continuation line as its first header line."""
|
|
|
|
|
|
2004-10-03 00:16:19 -03:00
|
|
|
|
class MisplacedEnvelopeHeaderDefect(MessageDefect):
|
2004-05-09 00:26:07 -03:00
|
|
|
|
"""A 'Unix-from' header was found in the middle of a header block."""
|
|
|
|
|
|
2004-10-03 00:16:19 -03:00
|
|
|
|
class MalformedHeaderDefect(MessageDefect):
|
|
|
|
|
"""Found a header that was missing a colon, or was otherwise malformed."""
|
|
|
|
|
|
|
|
|
|
class MultipartInvariantViolationDefect(MessageDefect):
|
|
|
|
|
"""A message claimed to be a multipart but no subparts were found."""
|