inherit-exception
What it does
Section titled “What it does”Reports a class that inherits Exception directly (class A < Exception, Class.new(Exception)).
Why it matters
Section titled “Why it matters”A plain rescue catches StandardError and its subclasses only. An exception that inherits Exception is not caught by it, and it is also not caught by code that handles all normal errors, so it ends the program, as does exit.
To fix, inherit from StandardError.
Example
Section titled “Example”class A < Exception; endclass B < StandardError... super(msg)...Configuration
Section titled “Configuration”ruby: lint: rules: inherit-exception: warn # off (default), warn, errorEnabled by the presets: ruby/rubocop.
Suppress one line with sudsy-disable-next-line inherit-exception in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| rubocop | Lint/InheritException |
full |