[erlang-questions] style question - best way to test multiple non-guard conditions sequentially
Daniil Churikov
ddosia@REDACTED
Mon Jun 24 14:51:47 CEST 2013
Hello Jonathan, hello list.
In _some_ cases to avoid such validation nesting I use try/catch and
pattern matching:
try
v1 = proplists:get_value(p1, L),
v2 = proplists:get_value(p2, L),
v3 = proplists:get_value(p3, L)
catch
_:_ ->
%% handle exception here and return
%% or re-throw it
false
end
But you should clearly understand what code you will wrap with try/catch.
It is possible hide some errors inside this block,
so i try not not wrap complex logic inside, only some input validators.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130624/06d5b9eb/attachment.htm>
More information about the erlang-questions
mailing list