smart exceptions
Serge Aleynikov
serge@REDACTED
Tue Mar 7 00:42:06 CET 2006
1. Am I correct to say that when using smart exceptions, the beam files
in jungerl/lib/smart_exceptions/ebin are only needed at compile-time and
not at run-time?
2. Is there a way to use smart_exceptions in order to include
function/line info in the uncaught throw exception?
$ cat test.erl
-module(test).
-export([t/1]).
t(1) ->
A = 1,
exit({error, A});
t(2) ->
100 / 0;
t(3) ->
A = abc,
{error, test} = {error, A};
t(4) ->
throw({error, test}).
$ erlc +'{parse_transform, smart_exceptions}' \
-pa jungerl/lib/smart_exceptions/ebin test.erl
# Note: we are not including a -pa argument for smart_exceptions
$ erl
Erlang (BEAM) emulator version 5.4.12 [source] [hipe] [threads:0]
Eshell V5.4.12 (abort with ^G)
1> [(catch test:t(N)) || N <- [1,2,3,4]].
[{'EXIT',{{test,t,1},{line,6},{error,1}}},
{'EXIT',{{test,t,1},
{line,9},
{badarith,[{test,t,1},
{erl_eval,do_apply,5},
{erl_eval,expr,5},
{erl_eval,eval_lc1,5},
{lists,flatmap,2},
{lists,flatmap,2},
{erl_eval,eval_lc,6},
{shell,exprs,6}]},
'/',
[100,0]}},
{'EXIT',{{test,t,1},{line,13},match,[{error,abc}]}},
{error,test}]
2> q().
--
Serge Aleynikov
R&D Telecom, IDT Corp.
Tel: (973) 438-3436
Fax: (973) 438-1464
serge@REDACTED
More information about the erlang-questions
mailing list