Ameba: [C] Style/RedundantBegin: Redundant `begin` block detected

I have the following function:

def process_wrapper(url)
    # Log.info { "hi "}
    begin
        process url
    rescue err
        Log.error { "There was an exception in #{url} #{err}" }
    end
    # Log.info { "hi "}
end

I wrote this because the “process” function was called from several places. I did not want to add exception handling to all of those places and I felt that putting a begin-rescue inside the “process” function wrapping all the statements would just make everything indented by one.
So I had this, probably not very brilliant, idea of writing a wrapper function.
It seems to work but ameba complains

C] Style/RedundantBegin: Redundant `begin` block detected

If I enable the logging statement either at the beginning or at the end of the function the ameba message goes away.

Why does ameba think it is redundant?

Because it can be written as

def process_wrapper(url)
  process url
rescue err
  Log.error { "There was an exception in #{url} #{err}" }
end
2 Likes

Thanks, that helped though I admit this looks strange.