Skip to content

Files

Latest commit

 

History

History
70 lines (54 loc) · 1.06 KB

Naming-RescuedExceptionsVariableName.md

File metadata and controls

70 lines (54 loc) · 1.06 KB

Pattern: Invalid rescued exception variable name

Issue: -

Description

Makes sure that rescued exceptions variables are named as expected.

The PreferredName config option takes a String. It represents the required name of the variable. Its default is e.

Examples

PreferredName: e (default)

# bad
begin
  # do something
rescue MyException => exception
  # do something
end

# good
begin
  # do something
rescue MyException => e
  # do something
end

# good
begin
  # do something
rescue MyException => _e
  # do something
end

PreferredName: exception

# bad
begin
  # do something
rescue MyException => e
  # do something
end

# good
begin
  # do something
rescue MyException => exception
  # do something
end

# good
begin
  # do something
rescue MyException => _exception
  # do something
end

Configurable attributes

Name Default value
PreferredName e

Further Reading