Correct me if I'm wrong but I think there are 1 (and a half) other ways you could write it - that don't result in branching
1:
def something(args) do
with {:ok, obj1} <- depencency1.call(args),
{:ok, obj2} <- dependency2.call(obj1),
{:ok, obj3} <- dependency2.call(obj2),
{:ok, obj4} <- dependency2.call(obj3),
{:ok, obj5} <- dependency2.call(obj4)
do
{:ok, obj5}
else
{:error, msg} -> {:error, msg}
end
end
1.5: Use a try/rescue block where you match {:ok, obj} and then catch Match errors.