Skip to content

raise-exception

Rubysuspiciousno fixdefault: offruby/rubocop

Reports raise Exception and raise Exception.new.

A plain rescue does not catch Exception, only StandardError, so the error goes past every handler that is written for normal errors and ends the program.

To fix, raise StandardError or a subclass.

Reported
...
raise Exception, "m"
raise StandardError
...
foo (a ? b : c)
...
ruby:
lint:
rules:
raise-exception: warn # off (default), warn, error

Enabled by the presets: ruby/rubocop.

Suppress one line with sudsy-disable-next-line raise-exception in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
rubocop Lint/RaiseException full