r/elixir • u/Friendly-Intern2839 • 18h ago
Reading errors in Elixir are like reading JSON
is there any better way? struggling to read the symbols elixir provides
...kind: :error
reason: %ArgumentError{
message: "errors were found at the given arguments:\n\n * 1st argument: the table identifier does not refer to an existing ETS table\n"
}
stack: [
{:ets, :select,
[
:"keys_Elixir.Hyper.Cluster.Routing",
[{{{:"$1", :supervisor}, :_, {:"$2", :_}}, [], [{{:"$1", :"$2"}}]}]
], [error_info: %{cause: :id, module: :erl_stdlib_errors}]},
{Horde.Registry, :select,
3
Upvotes
2
u/ZukowskiHardware 17h ago
Read from the bottom up. Most of the time they are quite descriptive. You can usually locate the call site and trace it yourself.
2
u/SuspiciousDepth5924 13h ago
It's mostly standard elixir datatypes, though this part:
is an erlang match spec (https://www.erlang.org/doc/apps/erts/match_spec.html) . Which is the weird not-sql query language that the built-in database uses.
Basically it's
[{ <rows_to_match>, [<optional_guard_clauses>], [<what_to_return>] }]here it seems to match{{variable1, :supervisor}, _, {variable2, _}}with no guards and returns{variable1, variable2}from all the matching rows, the return is wrapped in an extra tuple to tell erlang to treat it as an actual tuple instead of an instruction like {:is_float, :"$1"}.1
u/borromakot 16h ago
If you have an exception and a stack trace, use `Exception.format`.
1
u/adamtang7 5h ago
Hmm... It's easy to read if you have enough experience on elixir. May be channel to AI to get a brief description?