Because you should use:<br><br>> try lists:sort(abc) catch error:Why -> io:format("~p~n", [{Why, erlang:get_stacktrace()}]) end.<br>{function_clause,[{lists,sort,[abc]},<br>                  {erl_eval,do_apply,5},<br>
                  {erl_eval,try_clauses,8},<br>                  {shell,exprs,6},<br>                  {shell,eval_loop,3}]}<br>ok<br><br><div class="gmail_quote">On Mon, Apr 28, 2008 at 2:27 PM, Maxim Treskin <<a href="mailto:zerthurd@gmail.com">zerthurd@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello<br>
<br>
According Pragmatic Programming Erlang there is two syntax of exceptions:<br>
Old-style:<br>
<pre><br>
case (catch foo(...)) of<br>
    {'EXIT', Why} -><br>
        ...<br>
    Val -><br>
       ...<br>
end<br>
</pre><br>
<br>
and new-style:<br>
<pre><br>
try foo(...) of<br>
    Val -> ...<br>
catch<br>
    exit: Why -><br>
         ...<br>
end<br>
</pre><br>
<br>
If I use new-style syntax, I have not detailed exception cause<br>
explanation, like this:<br>
<pre><br>
3> try lists:sort([1,2,3]) catch exit:Why -> io:format("~p~n", [Why]) end.<br>
[1,2,3]<br>
4> try lists:sort(abc) catch exit:Why -> io:format("~p~n", [Why]) end.<br>
** exception error: function_clause<br>
</pre><br>
<br>
But if I use old-style syntax, I have this:<br>
<pre><br>
5> case (catch lists:sort(abc)) of {'EXIT', Why} -> io:format("~p~n",<br>
[Why]) end.<br>
{function_clause,[{lists,sort,[abc]},<br>
                  {erl_eval,do_apply,5},<br>
                  {erl_eval,expr,5},<br>
                  {erl_eval,expr,5},<br>
                  {shell,exprs,6},<br>
                  {shell,eval_exprs,6},<br>
                  {shell,eval_loop,3}]}<br>
ok<br>
</pre><br>
<br>
Can you say me, why is new-style better than old?<br>
<br>
Thank you<br>
<font color="#888888"><br>
--<br>
Maxim Treskin<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://www.erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>--Hynek (Pichi) Vychodil