You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.4 KiB

4 years ago
  1. """
  2. Scrapy core exceptions
  3. These exceptions are documented in docs/topics/exceptions.rst. Please don't add
  4. new exceptions here without documenting them there.
  5. """
  6. # Internal
  7. class NotConfigured(Exception):
  8. """Indicates a missing configuration situation"""
  9. pass
  10. # HTTP and crawling
  11. class IgnoreRequest(Exception):
  12. """Indicates a decision was made not to process a request"""
  13. class DontCloseSpider(Exception):
  14. """Request the spider not to be closed yet"""
  15. pass
  16. class CloseSpider(Exception):
  17. """Raise this from callbacks to request the spider to be closed"""
  18. def __init__(self, reason='cancelled'):
  19. super(CloseSpider, self).__init__()
  20. self.reason = reason
  21. # Items
  22. class DropItem(Exception):
  23. """Drop item from the item pipeline"""
  24. pass
  25. class NotSupported(Exception):
  26. """Indicates a feature or method is not supported"""
  27. pass
  28. # Commands
  29. class UsageError(Exception):
  30. """To indicate a command-line usage error"""
  31. def __init__(self, *a, **kw):
  32. self.print_help = kw.pop('print_help', True)
  33. super(UsageError, self).__init__(*a, **kw)
  34. class ScrapyDeprecationWarning(Warning):
  35. """Warning category for deprecated features, since the default
  36. DeprecationWarning is silenced on Python 2.7+
  37. """
  38. pass
  39. class ContractFail(AssertionError):
  40. """Error raised in case of a failing contract"""
  41. pass