[erlang-questions] About a simple program

Jon Schneider jon@REDACTED
Mon Nov 24 11:39:55 CET 2014


> Hi,
>      I write a simple Erlang program,But it doesnot function like what i
> think.

I think maybe it does do what you think but you haven't put anything in
there to make this visible. Also missing is a catch-all case.

start() ->
     lists:foreach(fun (I) ->
	J = try generate_exception(I) of
           Res -> Res
        catch
           throw:T -> T;
           exit:E -> E;
           error: Er -> Er;
           X1: X2 -> {X1,X2}
        end,
           io:format("exec this line:~p ~p~n",[I, J])
       end, lists:seq(1,5)).


then the output is

exec this line:1 a
exec this line:2 throw_exception
exec this line:3 error_exception
exec this line:4 exit_exception
exec this line:5 {'EXIT',a}

Jon




More information about the erlang-questions mailing list