class RuboCop::Cop::Lint::DuplicateRescueException
end
handle_other_exception
rescue SecondException
handle_exception
rescue FirstException
something
begin
# good
end
handle_other_exception
rescue FirstException
handle_exception
rescue FirstException
something
begin
# bad
@example
used in ‘rescue’ expressions.
Checks that there are no repeated exceptions
def on_rescue(node)
def on_rescue(node) return if rescue_modifier?(node) node.resbody_branches.each_with_object(Set.new) do |resbody, previous| rescued_exceptions = resbody.exceptions rescued_exceptions.each do |exception| add_offense(exception) unless previous.add?(exception) end end end