inspecting the call stack from a program (was: Re: Extending Functionality: an expedient and questionable approa ch)

Shawn Pearce <>
Wed Mar 19 20:17:17 CET 2003

Chris Pressey <> wrote:
> Sorry... I should have been more specific.  I meant - a way for a program
> to inspect the call stack.
> I'm currently using this function:
>   call_stack() ->
>     {'EXIT', {Error, CallStack}} = (catch 1 = 2),
>     tl(CallStack).
> I find this useful in conjunction with e.g. logging (e.g. in
> /jungerl/lib/ce/src/ce_log.erl)
> It's just that the "(catch 1 = 2)" strikes me as, uhm, ungraceful :)

So then use

     {'EXIT', {Error, CallStack}} = (catch 1 = undefined),


This is like the old Java trick of throwing an exception, catching it,
printing it to a stream, parsing the stream to locate the text of
the method you want, and pulling that back into a variable.  Oh wait,
its still cleaner in Erlang.


  * woot is now known as woot-dinner
  * Knghtbrd sprinkles a little salt on woot
  <Knghtbrd> I've never had a woot before...  Hope they taste good
  <woot-dinner> noooo!
  <woot-dinner> don't eat me!
  * Knghtbrd decides he does not want a dinner that talks to him...  hehe

More information about the erlang-questions mailing list