exceptions.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  2. # For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE
  3. # Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt
  4. """Exception classes raised by various operations within pylint."""
  5. class InvalidMessageError(Exception):
  6. """Raised when a message creation, registration or addition is rejected."""
  7. class UnknownMessageError(Exception):
  8. """Raised when an unregistered message id is encountered."""
  9. class DeletedMessageError(UnknownMessageError):
  10. """Raised when a message id or symbol that was deleted from pylint is
  11. encountered.
  12. """
  13. def __init__(self, msgid_or_symbol: str, removal_explanation: str):
  14. super().__init__(
  15. f"'{msgid_or_symbol}' was removed from pylint, see {removal_explanation}."
  16. )
  17. class MessageBecameExtensionError(UnknownMessageError):
  18. """Raised when a message id or symbol that was moved to an optional
  19. extension is encountered.
  20. """
  21. def __init__(self, msgid_or_symbol: str, moved_explanation: str):
  22. super().__init__(
  23. f"'{msgid_or_symbol}' was moved to an optional extension, see {moved_explanation}."
  24. )
  25. class EmptyReportError(Exception):
  26. """Raised when a report is empty and so should not be displayed."""
  27. class InvalidReporterError(Exception):
  28. """Raised when selected reporter is invalid (e.g. not found)."""
  29. class InvalidArgsError(ValueError):
  30. """Raised when passed arguments are invalid, e.g., have the wrong length."""
  31. class NoLineSuppliedError(Exception):
  32. """Raised when trying to disable a message on a next line without supplying a line
  33. number.
  34. """