errors.py 1.6 KB

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