exceptions.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. class FormParserError(ValueError):
  2. """Base error class for our form parser."""
  3. pass
  4. class ParseError(FormParserError):
  5. """This exception (or a subclass) is raised when there is an error while
  6. parsing something.
  7. """
  8. #: This is the offset in the input data chunk (*NOT* the overall stream) in
  9. #: which the parse error occurred. It will be -1 if not specified.
  10. offset = -1
  11. class MultipartParseError(ParseError):
  12. """This is a specific error that is raised when the MultipartParser detects
  13. an error while parsing.
  14. """
  15. pass
  16. class QuerystringParseError(ParseError):
  17. """This is a specific error that is raised when the QuerystringParser
  18. detects an error while parsing.
  19. """
  20. pass
  21. class DecodeError(ParseError):
  22. """This exception is raised when there is a decoding error - for example
  23. with the Base64Decoder or QuotedPrintableDecoder.
  24. """
  25. pass
  26. # On Python 3.3, IOError is the same as OSError, so we don't want to inherit
  27. # from both of them. We handle this case below.
  28. if IOError is not OSError: # pragma: no cover
  29. class FileError(FormParserError, IOError, OSError):
  30. """Exception class for problems with the File class."""
  31. pass
  32. else: # pragma: no cover
  33. class FileError(FormParserError, OSError):
  34. """Exception class for problems with the File class."""
  35. pass