Damm, i was thinking in this exactly solution, but it just seems so verbose. Take this example:
with {:parse_limit, {:ok, limit}} <- {:parse_limit, parse_limit(request)},
{:parse_offset, {:ok, offset}} <- {:parse_offset, parse_offset(request)},
{:parse_filters, {:ok, filters}} <- {:parse_filters, parse_filters(request)} do
# send the content back to user
else
{:parse_limit, :error} -> ...
{:parse_offset, :error} -> ...
{:parse_filters, :error} -> ...
end
It’s seems very verbose, and other thing, how can i handle the middle pre values? Imagine that the error happens on parse_filters, from the parse_filters error, how can i access the limit and offset?