try & error?
Mark Scandariato
mscandar@REDACTED
Fri Oct 15 17:24:09 CEST 2004
Hello,
The manual says that erlang:error/1,2 produces exceptions of class 'error', but it doesn't
seem to:
1>
1> Tst = fun(F) ->
1> try F()
1> catch
1> throw:T -> {'THROW', T};
1> error:R -> {'ERROR', R};
1> exit:R -> {'EXIT', R}
1> end
1> end.
#Fun<erl_eval.6.72228031>
2> Tst(fun() -> throw(foo) end).
{'THROW',foo}
3> Tst(fun() -> exit(foo) end).
{'EXIT',foo}
4> Tst(fun() -> erlang:error(foo) end).
{'EXIT',{foo,[{erl_eval,do_apply,5},
{erl_eval,try_fix,5},
{erl_eval,expr,5},
{shell,exprs,6},
{shell,eval_loop,3}]}}
5> Tst(fun() -> 3 = a end).
{'ERROR',{{badmatch,a},[{erl_eval,expr,3}]}}
6> Tst(fun() -> 3+a end).
{'ERROR',{badarith,[{erl_eval,eval_op,3},
{erl_eval,try_fix,5},
{erl_eval,expr,5},
{shell,exprs,6},
{shell,eval_loop,3}]}}
7>
Am I doing something wrong?
Mark.
More information about the erlang-questions
mailing list