Getting line number in backtrace?

Brian Candler <>
Fri Dec 3 15:49:52 CET 2010


Robert Virding wrote:
> Is the smart_exceptions module compiled and put in a place where erlc can find it?

It was certainly compiled:

$ ls -l ebin/smart_exceptions.beam ebin/mapform0.beam 
-rw-r--r-- 1 brian brian  1900 2010-12-02 19:51 ebin/mapform0.beam
-rw-r--r-- 1 brian brian 18936 2010-12-02 19:51 ebin/smart_exceptions.beam

However I hadn't added "-pa ebin" to the erlc command line, so it couldn't
find it. Thank you for pointing me in the right direction there.

I can now compile code with the smart_exceptions transformation, but the
exception output isn't any different:

$ rm ebin/my_test.beam 
$ rake
(in /v/git/rfe)
erlc -pa ebin +'{parse_transform,smart_exceptions}' +debug_info -o ebin src/my_test.erl
$ erl +Bc -pa ebin
Erlang R13B03 (erts-5.7.4) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]

Eshell V5.7.4  (abort with ^G)
1> my_test:go().
{foo,bar}** exception error: no match of right hand side value {foo,bar}
     in function  my_test:dostuff/1
     in call from my_test:go/0
2> my_test:dostuff({x,y}).
{x,y}** exception error: no match of right hand side value {x,y}
     in function  my_test:dostuff/1

Here's the source:

$ cat src/my_test.erl 
-module(my_test).
-export([go/0,dostuff/1]).

go() ->
  dostuff({foo,bar}),
  io:format("The end~n").

dostuff(A) ->
  io:write(A),
  {foo, baz} = A,
  io:format("Finished~n").


Cheers,

Brian.


More information about the erlang-questions mailing list