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

**URL:** <https://forum.crystal-lang.org/t/ameba-c-style-redundantbegin-redundant-begin-block-detected/3311>\
**Category:** Help & Support\
**Created:** [May 21, 2021, 7:32am UTC](https://forum.crystal-lang.org/t/ameba-c-style-redundantbegin-redundant-begin-block-detected/3311 "2021-05-21T07:32:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![szabgab](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/szabgab/32/1278_2.png) [@szabgab](https://forum.crystal-lang.org/u/szabgab)\
**Post date:** [May 21, 2021, 7:32am UTC](https://forum.crystal-lang.org/t/ameba-c-style-redundantbegin-redundant-begin-block-detected/3311/1 "2021-05-21T07:32:32Z")

</div>

I have the following function:

```auto
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

```auto
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?

---

<div class="post-metadata">

**Author:** ![jhass](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/jhass/32/1779_2.png) [@jhass](https://forum.crystal-lang.org/u/jhass)\
**Post date:** [May 21, 2021, 7:49am UTC](https://forum.crystal-lang.org/t/ameba-c-style-redundantbegin-redundant-begin-block-detected/3311/2 "2021-05-21T07:49:48Z")

</div>

Because it can be written as

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

---

<div class="post-metadata">

**Author:** ![szabgab](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/szabgab/32/1278_2.png) [@szabgab](https://forum.crystal-lang.org/u/szabgab)\
**Post date:** [May 21, 2021, 8:30am UTC](https://forum.crystal-lang.org/t/ameba-c-style-redundantbegin-redundant-begin-block-detected/3311/3 "2021-05-21T08:30:46Z")

</div>

Thanks, that helped though I admit this looks strange.
