A Python robot that edits Wikipedia and interacts with people over IRC https://en.wikipedia.org/wiki/User:EarwigBot
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

exceptions.py 2.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # -*- coding: utf-8 -*-
  2. """
  3. EarwigBot's Wiki Toolset: Exceptions
  4. This module contains all exceptions used by the wiki package. There are a lot.
  5. """
  6. class WikiToolsetError(Exception):
  7. """Base exception class for errors in the Wiki Toolset."""
  8. class SiteNotFoundError(WikiToolsetError):
  9. """A site matching the args given to get_site() could not be found in the
  10. config file."""
  11. class SiteAPIError(WikiToolsetError):
  12. """We couldn't connect to a site's API, perhaps because the server doesn't
  13. exist, our URL is wrong or incomplete, or they're having temporary
  14. problems."""
  15. class LoginError(WikiToolsetError):
  16. """An error occured while trying to login. Perhaps the username/password is
  17. incorrect."""
  18. class NamespaceNotFoundError(WikiToolsetError):
  19. """A requested namespace name or namespace ID does not exist."""
  20. class PageNotFoundError(WikiToolsetError):
  21. """Attempting to get certain information about a page that does not
  22. exist."""
  23. class InvalidPageError(WikiToolsetError):
  24. """Attempting to get certain information about a page whose title is
  25. invalid."""
  26. class RedirectError(WikiToolsetError):
  27. """Page's get_redirect_target() method failed because the page is either
  28. not a redirect, or it is malformed."""
  29. class UserNotFoundError(WikiToolsetError):
  30. """Attempting to get certain information about a user that does not
  31. exist."""
  32. class EditError(WikiToolsetError):
  33. """We got some error while editing. Sometimes, a subclass of this exception
  34. will be used, like PermissionsError or EditConflictError."""
  35. class PermissionsError(EditError):
  36. """We tried to do something we don't have permission to, like a non-admin
  37. trying to delete a page, or trying to edit a page when no login information
  38. was provided."""
  39. class EditConflictError(EditError):
  40. """We've gotten an edit conflict or a (rarer) delete/recreate conflict."""
  41. class NoContentError(EditError):
  42. """We tried to create a page or new section with no content."""
  43. class ContentTooBigError(EditError):
  44. """The edit we tried to push exceeded the article size limit."""
  45. class SpamDetectedError(EditError):
  46. """The spam filter refused our edit."""
  47. class FilteredError(EditError):
  48. """The edit filter refused our edit."""