SCR116: raise-string
raise with a string
| Code | SCR116 |
| Name | raise-string |
| Category | Scripts (SCR) |
| Default severity | error |
| Enabled by default | yes |
| Fix available | no |
| ign-lint equivalent | none |
What it does
Section titled “What it does”Reports raise "message", including strings built with % or + from a
string literal.
Why is this bad?
Section titled “Why is this bad?”String exceptions were removed in Python 2.6. Jython raises TypeError: exceptions must be old-style classes or derived from BaseException, not str instead of the intended error, and the message is lost.
Example
Section titled “Example”if not rows: raise "no data for line %s" % lineUse instead:
if not rows: raise ValueError("no data for line %s" % line)Generated from the rule metadata by iglint generate-docs; iglint rule SCR116 prints the same page in the terminal. Source: docs/rules/SCR116.md.