It’s typical to see this when programming in Elixir:
** (ArgumentError) argument error
Which can originate when a function calls:
erlang:error(badarg, SomeVariable).
But this isn’t very useful. If you’ve called a function with 4 arguments then you’re left guessing which one was wrong.
Instead of passing the symbol badarg
you can pass a tuple.
some_variable = 3
:erlang.error({:badarg, some_variable})
Which actually passes along the given value in the error output.
** (ArgumentError) argument error: 3
But that functionality is undocumented, :badarg
is listed by itself, not as a tuple in the documented exit reasons.
The telemetry
library calls the error function with just :badarg and it’s a not clear that you have to pass a list rather than just a symbol to the attach
function, https://github.com/beam-telemetry/telemetry/blob/master/src/telemetry.erl#L193.
It would be nice to change this error to be more informative in this library but I’m confused about what’s idiomatic or allowed for badargs
in Erlang.