# Error when using function in recon\_trace.calls

**URL:** <https://forum.elixirforum.com/t/error-when-using-function-in-recon-trace-calls/23193>\
**Category:** Questions\
**Tags:** tracing, recon\
**Created:** [June 17, 2019, 12:27pm UTC](https://forum.elixirforum.com/t/error-when-using-function-in-recon-trace-calls/23193 "2019-06-17T12:27:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fl4m3Ph03n1x](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fl4m3ph03n1x/32/11709_2.png) [@Fl4m3Ph03n1x](https://forum.elixirforum.com/u/Fl4m3Ph03n1x)\
**Post date:** [June 17, 2019, 12:27pm UTC](https://forum.elixirforum.com/t/error-when-using-function-in-recon-trace-calls/23193/1 "2019-06-17T12:27:37Z")

</div>

## Background

I have an app that is printing the following error every 2 or 3 seconds:

```elixir
=ERROR REPORT==== 14-Jun-2019::14:31:35.089496 ===
Unexpected message: {#Ref<0.2607974300.3493068808.175359>,badarg}

```

I want to find out it’s source.

## Error

To catch the process responsible, I am using [recon\_trace](https://ferd.github.io/recon/recon_trace.html#calls-3) the following way (an example follows):

```elixir
:recon_trace.calls({:system_information, :handle_info, fn({_ref, :badarg}, _state) -> :ok end}, 10)

```

However this is failing with the following error:

```elixir
:recon_trace.calls({:system_information, :handle_info, fn({_ref, :badarg}, _state) -> :ok end}, 10)
Error: dbg:fun2ms requires fun with single variable or list parameter
** (CaseClauseError) no case clause matching: {:error, :transform_error}
    (recon) src/recon_trace.erl:494: :recon_trace.validate_tspec/3
    (recon) src/recon_trace.erl:424: :recon_trace."-trace_calls/3-lc$^0/1-0-"/2
    (recon) src/recon_trace.erl:426: :recon_trace.trace_calls/3

```

I am quite confused here. My interpretation of the documentation suggests this should be possible, based on the following sample (in erlang):

> All calls to `iolist_to_binary/1` made with a binary as an argument already (kind of useless conversion!): `recon_trace:calls({erlang, iolist_to_binary, fun([X]) when is_binary(X) -> ok end}, 10)`

## Question

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![NobbZ](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nobbz/32/27235_2.png) [@NobbZ](https://forum.elixirforum.com/u/NobbZ)\
**Post date:** [June 17, 2019, 12:34pm UTC](https://forum.elixirforum.com/t/error-when-using-function-in-recon-trace-calls/23193/2 "2019-06-17T12:34:20Z")

</div>

You need to match on a list of argument in your match func. Similar to how you would specify a list in a MFA tuple.

* * *

_edit_

Back at a computer rather than a mobile:

```ex
:recon_trace.calls({:system_information, :handle_info, fn [{_ref, :badarg}, _state]) -> :ok end}, 10)

```

This might work…

---

<div class="post-metadata">

**Author:** ![Fl4m3Ph03n1x](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/fl4m3ph03n1x/32/11709_2.png) [@Fl4m3Ph03n1x](https://forum.elixirforum.com/u/Fl4m3Ph03n1x)\
**Post date:** [June 17, 2019, 12:38pm UTC](https://forum.elixirforum.com/t/error-when-using-function-in-recon-trace-calls/23193/3 "2019-06-17T12:38:12Z")

</div>

Like this?

`:recon_trace.calls({:system_information, :handle_info, fn([{ref, :badarg}, _state]) when is_reference(ref) -> :ok end}, 10)`

---

<div class="post-metadata">

**Author:** ![NobbZ](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/nobbz/32/27235_2.png) [@NobbZ](https://forum.elixirforum.com/u/NobbZ)\
**Post date:** [June 17, 2019, 12:39pm UTC](https://forum.elixirforum.com/t/error-when-using-function-in-recon-trace-calls/23193/4 "2019-06-17T12:39:30Z")

</div>

Yupp, as I edited it into my post seemingly at the same moment you posted as well 😉
