Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change
EnforcedStyle
to standard_error
for Lint/InheritException
This PR change `EnforcedStyle` from `runtime_error` to `standard_error` for `Lint/InheritException`. I noticed this while investigating rubocop#10406. Below is the inheritance tree for the exception classes. ``` --------------- | Exception | --------------- ^ | --------------- |StandardError| (default for `rescue`) --------------- ^ | --------------- |RuntimeError | (default for `raise`) --------------- ``` AFAIK, it seems that custom exceptions generally inherit from `StandardError`. Subclasses of `StandardError` are handled with `rescue` by default. `raise` creates a `RuntimeError` when the exception class is omitted. If custom exception inherits from `RuntimeError`, the custom exception and `RuntimeError` will be is-a. If custom exception inherits from `StandardError`, the custom exception and `RuntimeError` will not be is-a. In other words, inheriting `StandardError` will not be mistakenly handled as `raise` which omits the exception class. So, inheriting `StandardError` rather than `RuntimeError` does not include unnecessary inheritance for `rescue` handling.
- Loading branch information