Pattern: Constant overwritten in rescue
Issue: -
Checks for overwriting an exception with an exception result by using rescue ⇒
.
You intended to write as rescue StandardError
. However, you have written rescue ⇒ StandardError
. In that case, the result of rescue will overwrite StandardError
.
# bad
begin
something
rescue => StandardError
end
# good
begin
something
rescue StandardError
end