Avoid case nesting

Vladimir Sekissov svg@REDACTED
Sun Jan 13 19:00:23 CET 2002


Good day,

To avoid many nested cases I use following simple constract:

case catch
    begin
        {ok, MgrPid} = start_link(), %if wrong we'll get badmatch here
        ...
        {ok, GoodResult}        
    end of
    {'EXIT', {{badmatch, {error, Error}}, _}} ->
        {error, Error};
    {'EXIT', {{badmatch, Error}, _}} ->
        {error, Error};
    {'EXIT', Error} ->
            {error, Error};
    {ok, Result} ->
        Result
end.

Is there better and more elegant approaches?

Best Regards,

Vladimir Sekissov



More information about the erlang-questions mailing list