rescue
RB-W1023Avoid bubbling up exceptions with useless rescue
s (which only re-raise the errors) in your code as they are
inefficient and can make the control flow difficult to understand.
# bad
def foo
do_something
rescue
raise
end
# bad
def foo
do_something
rescue => e
raise # or 'raise e', or 'raise $!', or 'raise $ERROR_INFO'
end
# bad (last rescue does not do anything)
def foo
do_something
rescue ArgumentError
# noop
rescue
raise
end
def foo
rescue => e
ensure
end
def foo
do_something
rescue
do_cleanup
raise e
end
# Doesnt raise the same error
def foo
do_something
rescue => e
raise x
end