rspec/rules/S5632/description.adoc
Arseniy Zaostrovnykh 7ca29f686f Force linebreaks
2021-02-02 15:02:10 +01:00

8 lines
857 B
Plaintext

In Python 3, attempting to raise an object which does not derive from BaseException will raise a ``++TypeError++``. In Python 2 it is possible to raise old-style classes but this shouldn't be done anymore in order to be compatible with Python 3.
If you are about to create a custom Exception class, note that custom exceptions should inherit from ``++Exception++``, not ``++BaseException++``. ``++Exception++`` allows people to catch all exceptions except the ones explicitly asking the interpreter to stop, such as ``++KeyboardInterrupt++`` and https://docs.python.org/3/library/exceptions.html#GeneratorExit[``++GeneratorExit++``] which is not an error. See https://www.python.org/dev/peps/pep-0352/#exception-hierarchy-changes[PEP 352] for more information.
This rule raises an issue when an object which doesn't derive from BaseException is raised.