Skip to content

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

Reports raise "message", including strings built with % or + from a string literal.

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.

if not rows:
raise "no data for line %s" % line

Use 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.