no-throw-generic
What it does
Section titled “What it does”Reports a raise or throw of one of the generic types, itself or a call of it. Each language lists the types in its grammar’s rule row.
Why it matters
Section titled “Why it matters”A caller cannot tell a generic exception from any other error, so it can only catch everything or nothing, and the generic type also catches errors from other code. A specific type lets a caller handle the case.
To fix, raise a specific exception: a built-in one that fits (ValueError), or a class of your own.
Example
Section titled “Example”... pass
raise Exception("x")
...Configuration
Section titled “Configuration”python: lint: rules: no-throw-generic: level: warn # off (default), warn, error options: types: ["Exception"]| Option | Type | Default | Description |
|---|---|---|---|
types |
list | ["Exception"] |
Generic exception types |
Enabled by the presets: python/ruff.
Suppress one line with sudsy-disable-next-line no-throw-generic 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 |
|---|---|---|
| ruff | TRY002 |
full |