I have code like this (but bigger)
defmodule WithStacktrace do
def hello do
with {:ok, _value} <- {:ok, 1},
{:ok, value} <- :wrong_shape do
{:ok, value}
else
{:error, e} -> {:error, e}
end
end
end
This will raise:
** (WithClauseError) no with clause matching: :wrong_shape
(with_stacktrace 0.1.0) lib/with_stacktrace.ex:3: WithStacktrace.hello/0
So, the stack trace points to the beginning of the with
statement (line 3).
But the expression that matches neither its success case nor else
block is at line 4 {:ok, value} <- :wrong_shape
.
Let’s say my with
expression consists of 10 such calls. How can I easiest check which one returns the :wrong_shape
?
I am currently adding IO.inspect
s after each of those statements